Created
May 5, 2016 19:49
-
-
Save larsks/d5718949e2719173d0487745a97b382f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# deploy.sh [ -e <varspec> ] <host> <user> [<cidr>] | |
ansible_args=() | |
ansible_config=playbooks/centosci/minimal.yml | |
while getopts 'e:c:vC' ch; do | |
case $ch in | |
(e) ansible_args+=('-e') | |
ansible_args+=("$OPTARG") | |
;; | |
(c) ansible_config="$OPTARG" | |
;; | |
(v) ansible_args+=('-vvvv') | |
;; | |
(C) ansible_args+=('-e') | |
ansible_args+=('use_cached_image=true') | |
;; | |
esac | |
done | |
shift $(( $OPTIND - 1 )) | |
host=$1 | |
user=$2 | |
cidr=$3 | |
local_working_dir="$PWD/${user}@${host}" | |
mkdir -p $local_working_dir | |
inventory="$local_working_dir/deployhosts" | |
deploy_config="$local_working_dir/deployvars.yml" | |
cat > $inventory <<EOF | |
[virthost] | |
$host ansible_user=$user | |
EOF | |
cat > $deploy_config <<EOF | |
local_working_dir: $local_working_dir | |
EOF | |
[ "$cidr" ] && cat >> $deploy_config <<EOF | |
undercloud_external_network_cidr: $cidr | |
EOF | |
ansible-playbook \ | |
playbooks/deploy.yml \ | |
-i $inventory \ | |
-e @$ansible_config \ | |
-e @$deploy_config \ | |
${ansible_args[@]} \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment