Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 1 | --- |
| 2 | # roles/juju-setup/main/tasks.yml |
| 3 | |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 4 | - name: Initialize Juju |
| 5 | command: juju generate-config |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 6 | creates={{ ansible_user_dir }}/.juju/environments.yaml |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 7 | |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 8 | - name: Create Juju config file from template |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 9 | template: |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 10 | src=environments.yaml.j2 |
| 11 | dest={{ ansible_user_dir }}/.juju/environments.yaml |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 12 | |
| 13 | - name: Bootstrap Juju |
| 14 | command: juju bootstrap |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 15 | creates={{ ansible_user_dir }}/.juju/environments/manual.jenv |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 16 | |
Zack Williams | a627ae8 | 2016-04-13 12:37:10 -0700 | [diff] [blame] | 17 | - name: Copy over juju-config.yml for configuring Juju services |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 18 | become: yes |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 19 | template: |
Zack Williams | 684aa4c | 2016-04-14 07:04:38 -0700 | [diff] [blame] | 20 | src={{ juju_config_name }}_juju_config.yml.j2 |
Zack Williams | a627ae8 | 2016-04-13 12:37:10 -0700 | [diff] [blame] | 21 | dest={{ juju_config_path }} |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 22 | |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 23 | # Code for this is in library/juju_facts.py |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 24 | - name: Obtain Juju Facts for creating machines |
Zack Williams | 32e12fb | 2016-02-29 10:25:59 -0700 | [diff] [blame] | 25 | juju_facts: |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 26 | |
Zack Williams | 3dfe6af | 2016-04-30 11:37:09 -0700 | [diff] [blame] | 27 | - name: Pause to let Juju settle before adding machines |
| 28 | pause: |
| 29 | prompt="Waiting for Juju..." |
| 30 | seconds=20 |
| 31 | |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 32 | # For setwise operations on desired vs Juju state: |
Zack Williams | 32e12fb | 2016-02-29 10:25:59 -0700 | [diff] [blame] | 33 | # list of active juju_machines names: juju_machines.keys() |
Zack Williams | 823d529 | 2016-02-29 10:31:17 -0700 | [diff] [blame] | 34 | # list of active juju_services names: juju_services.keys() |
Zack Williams | 573bafc | 2016-02-26 16:35:42 -0700 | [diff] [blame] | 35 | |
Zack Williams | 9cdf862 | 2016-02-26 22:42:50 -0700 | [diff] [blame] | 36 | - name: Add machines to Juju |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 37 | when: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | map('format_string', '%s.'~site_suffix ) | difference( juju_machines.keys() ) | length }}" |
Zack Williams | 32e12fb | 2016-02-29 10:25:59 -0700 | [diff] [blame] | 38 | command: "juju add-machine ssh:{{ item }}" |
Zack Williams | 3dfe6af | 2016-04-30 11:37:09 -0700 | [diff] [blame] | 39 | with_items: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | map('format_string', '%s.'~site_suffix ) | difference( juju_machines.keys() ) }}" |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 40 | |
| 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 Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 44 | |
| 45 | - name: Deploy services that are hosted in their own VM |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 46 | when: "{{ vm_service_list | difference( juju_services.keys() ) | length }}" |
Zack Williams | c2248c4 | 2016-04-30 13:19:42 -0700 | [diff] [blame] | 47 | command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[item~'.'~site_suffix]['machine_id'] }} --config={{ juju_config_path }}" |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 48 | with_items: "{{ vm_service_list | difference( juju_services.keys() ) }}" |
| 49 | |
| 50 | - name: Deploy mongodb to ceilometer VM |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 51 | when: juju_services['mongodb'] is undefined |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 52 | command: "juju deploy {{ charm_versions['mongodb'] | default('mongodb') }} --to {{ juju_machines['ceilometer.'~site_suffix]['machine_id'] }} --config={{ juju_config_path }}" |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 53 | |
| 54 | - name: Deploy services that don't have their own VM |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 55 | when: "{{ standalone_service_list | difference( juju_services.keys() ) | length }}" |
Zack Williams | 9332a1c | 2016-04-13 15:14:47 -0700 | [diff] [blame] | 56 | command: "juju deploy {{ charm_versions[item] | default(item) }} --config={{ juju_config_path }}" |
Zack Williams | 0df6f2c | 2016-02-29 14:48:52 -0700 | [diff] [blame] | 57 | with_items: "{{ standalone_service_list | difference( juju_services.keys() ) }}" |
Zack Williams | 32e12fb | 2016-02-29 10:25:59 -0700 | [diff] [blame] | 58 | |
Zack Williams | 4bbfe1d | 2016-02-29 16:16:29 -0700 | [diff] [blame] | 59 | - name: Create relations between services |
| 60 | command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'" |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 61 | register: juju_relation |
| 62 | failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr" |
Zack Williams | 4bbfe1d | 2016-02-29 16:16:29 -0700 | [diff] [blame] | 63 | with_subelements: |
| 64 | - "{{ service_relations }}" |
| 65 | - relations |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 66 | tags: |
| 67 | - skip_ansible_lint # benign to do this more than once, hard to check for |
Zack Williams | 4bbfe1d | 2016-02-29 16:16:29 -0700 | [diff] [blame] | 68 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 69 | # run another time, so services will be in juju_services list |
| 70 | - name: Obtain Juju Facts after service creation |
| 71 | juju_facts: |
| 72 | |
Zack Williams | d13af16 | 2016-06-02 14:53:00 -0700 | [diff] [blame] | 73 | # 1800s = 30m. Usually takes 10-12m on cloudlab for relations to come up |
Zack Williams | 3dfe6af | 2016-04-30 11:37:09 -0700 | [diff] [blame] | 74 | # Only checks for first port in list |
Zack Williams | 70d512c | 2016-06-02 12:33:14 -0700 | [diff] [blame] | 75 | - name: Wait for juju services on VM's to have open ports |
Zack Williams | 7c35fac | 2016-04-11 23:52:43 -0700 | [diff] [blame] | 76 | wait_for: |
| 77 | host={{ item.name }} |
| 78 | port={{ item.forwarded_ports[0].int }} |
Zack Williams | d13af16 | 2016-06-02 14:53:00 -0700 | [diff] [blame] | 79 | timeout=1800 |
Zack Williams | 7c35fac | 2016-04-11 23:52:43 -0700 | [diff] [blame] | 80 | with_items: "{{ head_vm_list | selectattr('forwarded_ports', 'defined') | list }}" |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 81 | |
Zack Williams | abd5d86 | 2016-04-26 15:26:47 -0700 | [diff] [blame] | 82 | # secondary wait, as waiting on ports isn't enough. Probably only need one of these... |
Zack Williams | 70d512c | 2016-06-02 12:33:14 -0700 | [diff] [blame] | 83 | # 160*15s = 2400s = 40m max wait |
Zack Williams | abd5d86 | 2016-04-26 15:26:47 -0700 | [diff] [blame] | 84 | - name: Wait for juju services to start |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 85 | command: juju status --format=summary |
Zack Williams | abd5d86 | 2016-04-26 15:26:47 -0700 | [diff] [blame] | 86 | register: juju_summary |
| 87 | until: juju_summary.stdout.find("pending:") == -1 |
Zack Williams | 70d512c | 2016-06-02 12:33:14 -0700 | [diff] [blame] | 88 | retries: 160 |
Zack Williams | abd5d86 | 2016-04-26 15:26:47 -0700 | [diff] [blame] | 89 | delay: 15 |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 90 | tags: |
| 91 | - skip_ansible_lint # checking/waiting on a system to be up |
Zack Williams | abd5d86 | 2016-04-26 15:26:47 -0700 | [diff] [blame] | 92 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 93 | - 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 Bavier | c233512 | 2016-06-25 09:59:22 -0400 | [diff] [blame] | 100 | register: result |
| 101 | until: result | success |
Zack Williams | b364ef5 | 2016-08-17 17:18:22 -0700 | [diff] [blame] | 102 | retries: 40 |
Zack Williams | 6f5a6e7 | 2016-08-10 17:45:27 -0700 | [diff] [blame] | 103 | delay: 15 |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 104 | tags: |
| 105 | - skip_ansible_lint # checking/waiting on file availibilty |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 106 | |
Zack Williams | 008ce25 | 2016-04-30 14:39:15 -0700 | [diff] [blame] | 107 | - name: Copy cert to system location |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 108 | become: yes |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 109 | 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 Bavier | 0077cd2 | 2016-11-14 16:54:09 -0800 | [diff] [blame] | 113 | notify: |
| 114 | - update-ca-certificates |
| 115 | - Move cert to all service VMs |
| 116 | - update-ca-certificates in service VMs |