Created
February 6, 2016 20:56
-
-
Save danrough/752655d9423cf0840f37 to your computer and use it in GitHub Desktop.
Uses the meta module, introduced in Ansible 2.0, to refresh the inventory mid play
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
--- | |
- name: App servers | |
local_action: | |
module: rax | |
credentials: ~/.rackspace_cloud_credentials | |
region: "{{ region }}" | |
name: "{{ target_environment }}-{{ region }}-app-%02d" | |
count: "{{ app_server_count }}" | |
exact_count: yes | |
group: "{{ target_environment }}_app_servers" | |
meta: | |
groups: "{{ target_environment }},app_servers,{{ target_environment }}_nrpe_servers" | |
build_config: "core,monitoring" | |
files: | |
/root/.ssh/authorized_keys: "./ansible_key_{{ target_environment }}.pub" | |
flavor: "{{ app_server_rackspace_flavor }}" | |
image: "{{ debian8_image_id }}" | |
state: present | |
networks: | |
- private | |
- public | |
- "{{ network_name }}" | |
wait: yes | |
wait_timeout: 900 | |
register: new_app_servers | |
- meta: refresh_inventory | |
- name: Create A records for all new servers | |
local_action: | |
module: rax_dns_record | |
credentials: ~/.rackspace_cloud_credentials | |
domain: gamevy.com | |
name: "{{ item.name }}.gamevy.com" | |
data: "{{ item.rax_accessipv4 }}" | |
type: A | |
region: "{{ region }}" | |
with_items: "groups.{{ target_environment }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment