|
|
|
@ -136,15 +136,15 @@ For the following use case, let's use this small shell script as a wrapper.
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
PLAYBOOK="$1"
|
|
|
|
|
|
|
|
|
|
if [ -z $PLAYBOOK ]; then
|
|
|
|
|
echo "You need to pass a playback as argument to this script."
|
|
|
|
|
if [[ -z $PLAYBOOK ]]; then
|
|
|
|
|
echo "You need to pass a playbook as argument to this script."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
export SSL_CERT_FILE=$(pwd)/cacert.cer
|
|
|
|
|
export ANSIBLE_HOST_KEY_CHECKING=False
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$SSL_CERT_FILE" ]; then
|
|
|
|
|
if [[ ! -f "$SSL_CERT_FILE" ]]; then
|
|
|
|
|
curl -O http://curl.haxx.se/ca/cacert.pem
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -188,11 +188,14 @@ A playbook would looks like this:
|
|
|
|
|
wait_for: host={{ item.public_ip }} port=22 delay=10 timeout=60
|
|
|
|
|
with_items: gce.instance_data
|
|
|
|
|
|
|
|
|
|
- name: add_host hostname={{ item.public_ip }} groupname=new_instances
|
|
|
|
|
- name: Add host to groupname
|
|
|
|
|
add_host: hostname={{ item.public_ip }} groupname=new_instances
|
|
|
|
|
with_items: gce.instance_data
|
|
|
|
|
|
|
|
|
|
- name: Manage new instances
|
|
|
|
|
hosts: new_instances
|
|
|
|
|
connection: ssh
|
|
|
|
|
sudo: True
|
|
|
|
|
roles:
|
|
|
|
|
- base_configuration
|
|
|
|
|
- production_server
|
|
|
|
|