Created
February 6, 2016 09:40
-
-
Save danrough/13ae2e11e9101c41e80e to your computer and use it in GitHub Desktop.
Creates a server and registers the new server's facts to an ansible variable. Uses the registered variable to perform an additional task on the newly created server.
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 | |
- 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_flattened: | |
- new_app_servers.success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment