blob: e0ea5a00525b89b984fd0f5455f6162351995f7c [file] [log] [blame]
Zack Williams573bafc2016-02-26 16:35:42 -07001---
2# roles/juju-setup/main/tasks.yml
3
Zack Williams573bafc2016-02-26 16:35:42 -07004- name: Initialize Juju
5 command: juju generate-config
Zack Williams823d5292016-02-29 10:31:17 -07006 creates={{ ansible_user_dir }}/.juju/environments.yaml
Zack Williams573bafc2016-02-26 16:35:42 -07007
Zack Williams823d5292016-02-29 10:31:17 -07008- name: Create Juju config file from template
Zack Williams573bafc2016-02-26 16:35:42 -07009 template:
Zack Williams823d5292016-02-29 10:31:17 -070010 src=environments.yaml.j2
11 dest={{ ansible_user_dir }}/.juju/environments.yaml
Zack Williams573bafc2016-02-26 16:35:42 -070012
13- name: Bootstrap Juju
14 command: juju bootstrap
Zack Williams823d5292016-02-29 10:31:17 -070015 creates={{ ansible_user_dir }}/.juju/environments/manual.jenv
Zack Williams573bafc2016-02-26 16:35:42 -070016
Zack Williamsa627ae82016-04-13 12:37:10 -070017- name: Copy over juju-config.yml for configuring Juju services
Zack Williams573bafc2016-02-26 16:35:42 -070018 become: yes
Zack Williams0df6f2c2016-02-29 14:48:52 -070019 template:
Zack Williams684aa4c2016-04-14 07:04:38 -070020 src={{ juju_config_name }}_juju_config.yml.j2
Zack Williamsa627ae82016-04-13 12:37:10 -070021 dest={{ juju_config_path }}
Zack Williams573bafc2016-02-26 16:35:42 -070022
Zack Williams0df6f2c2016-02-29 14:48:52 -070023# Code for this is in library/juju_facts.py
Zack Williams709f11b2016-03-17 14:29:51 -070024- name: Obtain Juju Facts for creating machines
Zack Williams32e12fb2016-02-29 10:25:59 -070025 juju_facts:
Zack Williams573bafc2016-02-26 16:35:42 -070026
Zack Williams3dfe6af2016-04-30 11:37:09 -070027- name: Pause to let Juju settle before adding machines
28 pause:
29 prompt="Waiting for Juju..."
30 seconds=20
31
Zack Williams823d5292016-02-29 10:31:17 -070032# For setwise operations on desired vs Juju state:
Zack Williams32e12fb2016-02-29 10:25:59 -070033# list of active juju_machines names: juju_machines.keys()
Zack Williams823d5292016-02-29 10:31:17 -070034# list of active juju_services names: juju_services.keys()
Zack Williams573bafc2016-02-26 16:35:42 -070035
Zack Williams9cdf8622016-02-26 22:42:50 -070036- name: Add machines to Juju
Zack Williams35624562016-08-28 17:12:26 -070037 when: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | map('format_string', '%s.'~site_suffix ) | difference( juju_machines.keys() ) | length }}"
Zack Williams32e12fb2016-02-29 10:25:59 -070038 command: "juju add-machine ssh:{{ item }}"
Zack Williams3dfe6af2016-04-30 11:37:09 -070039 with_items: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | map('format_string', '%s.'~site_suffix ) | difference( juju_machines.keys() ) }}"
Zack Williams709f11b2016-03-17 14:29:51 -070040
41# run this again, so machines will be in the juju_machines list
42- name: Obtain Juju Facts after machine creation
43 juju_facts:
Zack Williams0df6f2c2016-02-29 14:48:52 -070044
45- name: Deploy services that are hosted in their own VM
Zack Williams35624562016-08-28 17:12:26 -070046 when: "{{ vm_service_list | difference( juju_services.keys() ) | length }}"
Zack Williamsc2248c42016-04-30 13:19:42 -070047 command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[item~'.'~site_suffix]['machine_id'] }} --config={{ juju_config_path }}"
Zack Williams0df6f2c2016-02-29 14:48:52 -070048 with_items: "{{ vm_service_list | difference( juju_services.keys() ) }}"
49
50- name: Deploy mongodb to ceilometer VM
Zack Williams0df6f2c2016-02-29 14:48:52 -070051 when: juju_services['mongodb'] is undefined
Zack Williams35624562016-08-28 17:12:26 -070052 command: "juju deploy {{ charm_versions['mongodb'] | default('mongodb') }} --to {{ juju_machines['ceilometer.'~site_suffix]['machine_id'] }} --config={{ juju_config_path }}"
Zack Williams0df6f2c2016-02-29 14:48:52 -070053
54- name: Deploy services that don't have their own VM
Zack Williams35624562016-08-28 17:12:26 -070055 when: "{{ standalone_service_list | difference( juju_services.keys() ) | length }}"
Zack Williams9332a1c2016-04-13 15:14:47 -070056 command: "juju deploy {{ charm_versions[item] | default(item) }} --config={{ juju_config_path }}"
Zack Williams0df6f2c2016-02-29 14:48:52 -070057 with_items: "{{ standalone_service_list | difference( juju_services.keys() ) }}"
Zack Williams32e12fb2016-02-29 10:25:59 -070058
Zack Williams4bbfe1d2016-02-29 16:16:29 -070059- name: Create relations between services
60 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
Zack Williams709f11b2016-03-17 14:29:51 -070061 register: juju_relation
62 failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr"
Zack Williams4bbfe1d2016-02-29 16:16:29 -070063 with_subelements:
64 - "{{ service_relations }}"
65 - relations
Zack Williams35624562016-08-28 17:12:26 -070066 tags:
67 - skip_ansible_lint # benign to do this more than once, hard to check for
Zack Williams4bbfe1d2016-02-29 16:16:29 -070068
Zack Williams709f11b2016-03-17 14:29:51 -070069# run another time, so services will be in juju_services list
70- name: Obtain Juju Facts after service creation
71 juju_facts:
72
Zack Williamsd13af162016-06-02 14:53:00 -070073# 1800s = 30m. Usually takes 10-12m on cloudlab for relations to come up
Zack Williams3dfe6af2016-04-30 11:37:09 -070074# Only checks for first port in list
Zack Williams70d512c2016-06-02 12:33:14 -070075- name: Wait for juju services on VM's to have open ports
Zack Williams7c35fac2016-04-11 23:52:43 -070076 wait_for:
77 host={{ item.name }}
78 port={{ item.forwarded_ports[0].int }}
Zack Williamsd13af162016-06-02 14:53:00 -070079 timeout=1800
Zack Williams7c35fac2016-04-11 23:52:43 -070080 with_items: "{{ head_vm_list | selectattr('forwarded_ports', 'defined') | list }}"
Zack Williams709f11b2016-03-17 14:29:51 -070081
Zack Williamsabd5d862016-04-26 15:26:47 -070082# secondary wait, as waiting on ports isn't enough. Probably only need one of these...
Zack Williams70d512c2016-06-02 12:33:14 -070083# 160*15s = 2400s = 40m max wait
Zack Williamsabd5d862016-04-26 15:26:47 -070084- name: Wait for juju services to start
Zack Williams35624562016-08-28 17:12:26 -070085 command: juju status --format=summary
Zack Williamsabd5d862016-04-26 15:26:47 -070086 register: juju_summary
87 until: juju_summary.stdout.find("pending:") == -1
Zack Williams70d512c2016-06-02 12:33:14 -070088 retries: 160
Zack Williamsabd5d862016-04-26 15:26:47 -070089 delay: 15
Zack Williams35624562016-08-28 17:12:26 -070090 tags:
91 - skip_ansible_lint # checking/waiting on a system to be up
Zack Williamsabd5d862016-04-26 15:26:47 -070092
Zack Williams709f11b2016-03-17 14:29:51 -070093- name: Create admin-openrc.sh credentials file
94 template:
95 src=admin-openrc.sh.j2
96 dest={{ ansible_user_dir }}/admin-openrc.sh
97
98- name: Copy nova-cloud-controller CA certificate to head
99 command: juju scp {{ juju_services['nova-cloud-controller']['units'].keys()[0] }}:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt {{ ansible_user_dir }}
Andy Bavierc2335122016-06-25 09:59:22 -0400100 register: result
101 until: result | success
Zack Williamsb364ef52016-08-17 17:18:22 -0700102 retries: 40
Zack Williams6f5a6e72016-08-10 17:45:27 -0700103 delay: 15
Zack Williams35624562016-08-28 17:12:26 -0700104 tags:
105 - skip_ansible_lint # checking/waiting on file availibilty
Zack Williams709f11b2016-03-17 14:29:51 -0700106
Zack Williams008ce252016-04-30 14:39:15 -0700107- name: Copy cert to system location
Zack Williams709f11b2016-03-17 14:29:51 -0700108 become: yes
Zack Williams35624562016-08-28 17:12:26 -0700109 copy:
110 src: "{{ ansible_user_dir }}/keystone_juju_ca_cert.crt"
111 dest: "/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt"
112 remote_src: true
Andy Bavier0077cd22016-11-14 16:54:09 -0800113 notify:
114 - update-ca-certificates
115 - Move cert to all service VMs
116 - update-ca-certificates in service VMs