diff options
author | Øystein Bedin <oybed@users.noreply.github.com> | 2017-10-02 21:08:45 +0000 |
---|---|---|
committer | Eric Sauer <etsauer@gmail.com> | 2017-10-02 16:08:45 -0500 |
commit | 15be1ebcf1705bc5e9347463594f50cc9d0f27b4 (patch) | |
tree | 5565e56bf6f24134bbd1c6985f3c4de15ca4a96f /roles/openstack-stack | |
parent | 7fdb0ae9234b8ee432c517a02f329a7e82c88728 (diff) | |
download | openshift-15be1ebcf1705bc5e9347463594f50cc9d0f27b4.tar.gz openshift-15be1ebcf1705bc5e9347463594f50cc9d0f27b4.tar.bz2 openshift-15be1ebcf1705bc5e9347463594f50cc9d0f27b4.tar.xz openshift-15be1ebcf1705bc5e9347463594f50cc9d0f27b4.zip |
Adding the option to use 'stack_state' to allow for easy de-provisioning (#754)
* Adding 'openstack-stack-delete' role to allow for easy de-provisioning
* Updated per etsauer's comments
Diffstat (limited to 'roles/openstack-stack')
-rw-r--r-- | roles/openstack-stack/defaults/main.yml | 3 | ||||
-rw-r--r-- | roles/openstack-stack/tasks/cleanup.yml | 6 | ||||
-rw-r--r-- | roles/openstack-stack/tasks/generate-templates.yml | 32 | ||||
-rw-r--r-- | roles/openstack-stack/tasks/main.yml | 54 |
4 files changed, 56 insertions, 39 deletions
diff --git a/roles/openstack-stack/defaults/main.yml b/roles/openstack-stack/defaults/main.yml index c16b5dc00..6f1949286 100644 --- a/roles/openstack-stack/defaults/main.yml +++ b/roles/openstack-stack/defaults/main.yml @@ -1,4 +1,7 @@ --- + +stack_state: 'present' + ssh_ingress_cidr: 0.0.0.0/0 node_ingress_cidr: 0.0.0.0/0 master_ingress_cidr: 0.0.0.0/0 diff --git a/roles/openstack-stack/tasks/cleanup.yml b/roles/openstack-stack/tasks/cleanup.yml new file mode 100644 index 000000000..258334a6b --- /dev/null +++ b/roles/openstack-stack/tasks/cleanup.yml @@ -0,0 +1,6 @@ +--- + +- name: cleanup temp files + file: + path: "{{ stack_template_pre.path }}" + state: absent diff --git a/roles/openstack-stack/tasks/generate-templates.yml b/roles/openstack-stack/tasks/generate-templates.yml new file mode 100644 index 000000000..0ce9a3eec --- /dev/null +++ b/roles/openstack-stack/tasks/generate-templates.yml @@ -0,0 +1,32 @@ +--- +- name: create HOT stack template prefix + register: stack_template_pre + tempfile: + state: directory + prefix: casl-ansible + +- name: set template paths + set_fact: + stack_template_path: "{{ stack_template_pre.path }}/stack.yaml" + user_data_template_path: "{{ stack_template_pre.path }}/user-data" + +- name: generate HOT stack template from jinja2 template + template: + src: heat_stack.yaml.j2 + dest: "{{ stack_template_path }}" + +- name: generate HOT server template from jinja2 template + template: + src: heat_stack_server.yaml.j2 + dest: "{{ stack_template_pre.path }}/server.yaml" + +- name: generate HOT server w/o floating IPs template from jinja2 template + template: + src: heat_stack_server_nofloating.yaml.j2 + dest: "{{ stack_template_pre.path }}/server_nofloating.yaml" + when: use_bastion|bool + +- name: generate user_data from jinja2 template + template: + src: user_data.j2 + dest: "{{ user_data_template_path }}" diff --git a/roles/openstack-stack/tasks/main.yml b/roles/openstack-stack/tasks/main.yml index 9b4855294..983567026 100644 --- a/roles/openstack-stack/tasks/main.yml +++ b/roles/openstack-stack/tasks/main.yml @@ -1,51 +1,27 @@ --- -- name: create HOT stack template prefix - register: stack_template_pre - tempfile: - state: directory - prefix: casl-ansible -- name: set template paths - set_fact: - stack_template_path: "{{ stack_template_pre.path }}/stack.yaml" - user_data_template_path: "{{ stack_template_pre.path }}/user-data" +- name: Generate the templates + include: generate-templates.yml + when: + - stack_state == 'present' -- name: generate HOT stack template from jinja2 template - template: - src: heat_stack.yaml.j2 - dest: "{{ stack_template_path }}" - -- name: generate HOT server template from jinja2 template - template: - src: heat_stack_server.yaml.j2 - dest: "{{ stack_template_pre.path }}/server.yaml" - -- name: generate HOT server w/o floating IPs template from jinja2 template - template: - src: heat_stack_server_nofloating.yaml.j2 - dest: "{{ stack_template_pre.path }}/server_nofloating.yaml" - when: use_bastion|bool - -- name: generate user_data from jinja2 template - template: - src: user_data.j2 - dest: "{{ user_data_template_path }}" - -- name: create stack +- name: Handle the Stack (create/delete) ignore_errors: False register: stack_create os_stack: name: "{{ stack_name }}" - state: present - template: "{{ stack_template_path }}" + state: "{{ stack_state }}" + template: "{{ stack_template_path | default(omit) }}" wait: yes # NOTE(bogdando) OS::Neutron::Subnet doesn't support live updates for # dns_nameservers, so we can't do that for the "create stack" task. - include: subnet_update_dns_servers.yaml - when: private_dns_server is defined - -- name: cleanup temp files - file: - path: "{{ stack_template_pre.path }}" - state: absent + when: + - private_dns_server is defined + - stack_state == 'present' + +- name: CleanUp + include: cleanup.yml + when: + - stack_state == 'present' |