summaryrefslogtreecommitdiff
path: root/docsite
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-07-14 10:44:53 -0500
committerJames Cammarata <jimi@sngx.net>2014-07-14 10:44:53 -0500
commite3abaa30b6343aca645f52f04b783cfa3d9dcd15 (patch)
tree446701de1a1d08f6d708e898ffbc45dd2e36989c /docsite
parentd52b50cb0392a5a823b6dd943ca59d3d79e1aa01 (diff)
parent074263af8de039df9a06f950cdd96755806f347d (diff)
downloadansible-e3abaa30b6343aca645f52f04b783cfa3d9dcd15.tar.gz
Merge pull request #7650 from sivel/guide-rax-automation
Rax Guide: Add RackConnect and Managed Cloud automation check examples
Diffstat (limited to 'docsite')
-rw-r--r--docsite/rst/guide_rax.rst227
1 files changed, 221 insertions, 6 deletions
diff --git a/docsite/rst/guide_rax.rst b/docsite/rst/guide_rax.rst
index 745f38fe5d..1efbd154c6 100644
--- a/docsite/rst/guide_rax.rst
+++ b/docsite/rst/guide_rax.rst
@@ -407,10 +407,10 @@ Use Cases
This section covers some additional usage examples built around a specific use case.
-.. _example_1:
+.. _network_and_server:
-Example 1
-+++++++++
+Network and Server
+++++++++++++++++++
Create an isolated cloud network and build a server
@@ -450,10 +450,10 @@ Create an isolated cloud network and build a server
wait_timeout: 360
register: rax
-.. _example_2:
+.. _complete_environment:
-Example 2
-+++++++++
+Complete Environment
+++++++++++++++++++++
Build a complete webserver environment with servers, custom networks and load balancers, install nginx and create a custom index.html
@@ -556,6 +556,221 @@ Build a complete webserver environment with servers, custom networks and load ba
copy: content="{{ inventory_hostname }}" dest=/usr/share/nginx/www/index.html
owner=root group=root mode=0644
+.. _rackconnect_and_manged_cloud:
+
+RackConnect and Managed Cloud
++++++++++++++++++++++++++++++
+
+When using RackConnect version 2 or Rackspace Managed Cloud there are Rackspace automation tasks that are executed on the servers you create after they are successfully built. If your automation executes before the RackConnect or Managed Cloud automation, you can cause failures and un-usable servers.
+
+These examples show creating servers, and ensuring that the Rackspace automation has completed before Ansible continues onwards.
+
+For simplicity, these examples are joined, however both are only needed when using RackConnect. When only using Managed Cloud, the RackConnect portion can be ignored.
+
+The RackConnect portions only apply to RackConnect version 2.
+
+.. _using_a_control_machine:
+
+Using a Control Machine
+***********************
+
+.. code-block:: yaml
+
+ - name: Create an exact count of servers
+ hosts: localhost
+ connection: local
+ gather_facts: False
+ tasks:
+ - name: Server build requests
+ local_action:
+ module: rax
+ credentials: ~/.raxpub
+ name: web%03d.example.org
+ flavor: performance1-1
+ image: ubuntu-1204-lts-precise-pangolin
+ disk_config: manual
+ region: DFW
+ state: present
+ count: 1
+ exact_count: yes
+ group: web
+ wait: yes
+ register: rax
+
+ - name: Add servers to in memory groups
+ local_action:
+ module: add_host
+ hostname: "{{ item.name }}"
+ ansible_ssh_host: "{{ item.rax_accessipv4 }}"
+ ansible_ssh_pass: "{{ item.rax_adminpass }}"
+ ansible_ssh_user: root
+ rax_id: "{{ item.rax_id }}"
+ groups: web,new_web
+ with_items: rax.success
+ when: rax.action == 'create'
+
+ - name: Wait for rackconnect and managed cloud automation to complete
+ hosts: new_web
+ gather_facts: false
+ tasks:
+ - name: Wait for rackconnnect automation to complete
+ local_action:
+ module: rax_facts
+ credentials: ~/.raxpub
+ id: "{{ rax_id }}"
+ region: DFW
+ register: rax_facts
+ until: rax_facts.ansible_facts['rax_metadata']['rackconnect_automation_status']|default('') == 'DEPLOYED'
+ retries: 30
+ delay: 10
+
+ - name: Wait for managed cloud automation to complete
+ local_action:
+ module: rax_facts
+ credentials: ~/.raxpub
+ id: "{{ rax_id }}"
+ region: DFW
+ register: rax_facts
+ until: rax_facts.ansible_facts['rax_metadata']['rax_service_level_automation']|default('') == 'Complete'
+ retries: 30
+ delay: 10
+
+ - name: Base Configure Servers
+ hosts: web
+ roles:
+ - role: users
+
+ - role: openssh
+ opensshd_PermitRootLogin: "no"
+
+ - role: ntp
+
+.. _using_ansible_pull:
+
+Using Ansible Pull
+******************
+
+.. code-block:: yaml
+
+ ---
+ - name: Ensure Rackconnect and Managed Cloud Automation is complete
+ hosts: all
+ connection: local
+ tasks:
+ - name: Check for completed bootstrap
+ stat:
+ path: /etc/bootstrap_complete
+ register: bootstrap
+
+ - name: Get region
+ command: xenstore-read vm-data/provider_data/region
+ register: rax_region
+ when: bootstrap.stat.exists != True
+
+ - name: Wait for rackconnect automation to complete
+ uri:
+ url: "https://{{ rax_region.stdout|trim }}.api.rackconnect.rackspace.com/v1/automation_status?format=json"
+ return_content: yes
+ register: automation_status
+ when: bootstrap.stat.exists != True
+ until: automation_status['automation_status']|default('') == 'DEPLOYED'
+ retries: 30
+ delay: 10
+
+ - name: Wait for managed cloud automation to complete
+ wait_for:
+ path: /tmp/rs_managed_cloud_automation_complete
+ delay: 10
+ when: bootstrap.stat.exists != True
+
+ - name: Set bootstrap completed
+ file:
+ path: /etc/bootstrap_complete
+ state: touch
+ owner: root
+ group: root
+ mode: 0400
+
+ - name: Base Configure Servers
+ hosts: all
+ connection: local
+ roles:
+ - role: users
+
+ - role: openssh
+ opensshd_PermitRootLogin: "no"
+
+ - role: ntp
+
+.. _using_ansible_pull_with_xenstore:
+
+Using Ansible Pull with XenStore
+********************************
+
+.. code-block:: yaml
+
+ ---
+ - name: Ensure Rackconnect and Managed Cloud Automation is complete
+ hosts: all
+ connection: local
+ tasks:
+ - name: Check for completed bootstrap
+ stat:
+ path: /etc/bootstrap_complete
+ register: bootstrap
+
+ - name: Wait for rackconnect_automation_status xenstore key to exist
+ command: xenstore-exists vm-data/user-metadata/rackconnect_automation_status
+ register: rcas_exists
+ when: bootstrap.stat.exists != True
+ failed_when: rcas_exists.rc|int > 1
+ until: rcas_exists.rc|int == 0
+ retries: 30
+ delay: 10
+
+ - name: Wait for rackconnect automation to complete
+ command: xenstore-read vm-data/user-metadata/rackconnect_automation_status
+ register: rcas
+ when: bootstrap.stat.exists != True
+ until: rcas.stdout|replace('"', '') == 'DEPLOYED'
+ retries: 30
+ delay: 10
+
+ - name: Wait for rax_service_level_automation xenstore key to exist
+ command: xenstore-exists vm-data/user-metadata/rax_service_level_automation
+ register: rsla_exists
+ when: bootstrap.stat.exists != True
+ failed_when: rsla_exists.rc|int > 1
+ until: rsla_exists.rc|int == 0
+ retries: 30
+ delay: 10
+
+ - name: Wait for managed cloud automation to complete
+ command: xenstore-read vm-data/user-metadata/rackconnect_automation_status
+ register: rsla
+ when: bootstrap.stat.exists != True
+ until: rsla.stdout|replace('"', '') == 'DEPLOYED'
+ retries: 30
+ delay: 10
+
+ - name: Set bootstrap completed
+ file:
+ path: /etc/bootstrap_complete
+ state: touch
+ owner: root
+ group: root
+ mode: 0400
+
+ - name: Base Configure Servers
+ hosts: all
+ connection: local
+ roles:
+ - role: users
+
+ - role: openssh
+ opensshd_PermitRootLogin: "no"
+
+ - role: ntp
.. _advanced_usage: