Last active
February 18, 2016 01:18
-
-
Save qrtt1/b05611f7bb827ffb6813 to your computer and use it in GitHub Desktop.
Ansible Dynamic Inventory
This file contains hidden or 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/env sh | |
gcloud compute instances list --regexp .*foobarbar.* --format json \ | |
| jq '{"web":{"vars": {"ansible_ssh_user":"i_am_the_king_of_the_world", "ansible_ssh_private_key_file":"/opt/ansible_pass.pem"}, "hosts": [.[].networkInterfaces[].accessConfigs[].natIP]}}' | |
exit 0 |
This file contains hidden or 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
{ | |
"web": { | |
"vars": { | |
"ansible_ssh_user": "i_am_the_king_of_the_world", | |
"ansible_ssh_private_key_file": "/opt/ansible_pass.pem" | |
}, | |
"hosts": [ | |
"130.231.253.55", | |
"104.100.153.66" | |
] | |
} | |
} |
This file contains hidden or 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
--- | |
- hosts: web | |
sudo: yes | |
serial: 1 | |
post_tasks: | |
- wait_for: port=3033 | |
tasks: | |
- command: "update-you-software" | |
- command: forever restartall | |
# Run | |
# ansible-playbook -i nodelist.sh server_refresh.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment