blob: 6bd790dd7d25a1ddcdbf707111c56f2ae2c09daf [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 Williams32e12fb2016-02-29 10:25:59 -070037 command: "juju add-machine ssh:{{ item }}"
Zack Williams3dfe6af2016-04-30 11:37:09 -070038 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 -070039
40# run this again, so machines will be in the juju_machines list
41- name: Obtain Juju Facts after machine creation
42 juju_facts:
Zack Williams0df6f2c2016-02-29 14:48:52 -070043
44- name: Deploy services that are hosted in their own VM
Zack Williamsc2248c42016-04-30 13:19:42 -070045 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 -070046 with_items: "{{ vm_service_list | difference( juju_services.keys() ) }}"
47
48- name: Deploy mongodb to ceilometer VM
Zack Williamsc2248c42016-04-30 13:19:42 -070049 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 -070050 when: juju_services['mongodb'] is undefined
51
52- name: Deploy services that don't have their own VM
Zack Williams9332a1c2016-04-13 15:14:47 -070053 command: "juju deploy {{ charm_versions[item] | default(item) }} --config={{ juju_config_path }}"
Zack Williams0df6f2c2016-02-29 14:48:52 -070054 with_items: "{{ standalone_service_list | difference( juju_services.keys() ) }}"
Zack Williams32e12fb2016-02-29 10:25:59 -070055
Zack Williams4bbfe1d2016-02-29 16:16:29 -070056- name: Create relations between services
57 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
Zack Williams709f11b2016-03-17 14:29:51 -070058 register: juju_relation
59 failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr"
Zack Williams4bbfe1d2016-02-29 16:16:29 -070060 with_subelements:
61 - "{{ service_relations }}"
62 - relations
63
Zack Williams709f11b2016-03-17 14:29:51 -070064# run another time, so services will be in juju_services list
65- name: Obtain Juju Facts after service creation
66 juju_facts:
67
Zack Williamsd13af162016-06-02 14:53:00 -070068# 1800s = 30m. Usually takes 10-12m on cloudlab for relations to come up
Zack Williams3dfe6af2016-04-30 11:37:09 -070069# Only checks for first port in list
Zack Williams70d512c2016-06-02 12:33:14 -070070- name: Wait for juju services on VM's to have open ports
Zack Williams7c35fac2016-04-11 23:52:43 -070071 wait_for:
72 host={{ item.name }}
73 port={{ item.forwarded_ports[0].int }}
Zack Williamsd13af162016-06-02 14:53:00 -070074 timeout=1800
Zack Williams7c35fac2016-04-11 23:52:43 -070075 with_items: "{{ head_vm_list | selectattr('forwarded_ports', 'defined') | list }}"
Zack Williams709f11b2016-03-17 14:29:51 -070076
Zack Williamsabd5d862016-04-26 15:26:47 -070077# secondary wait, as waiting on ports isn't enough. Probably only need one of these...
Zack Williams70d512c2016-06-02 12:33:14 -070078# 160*15s = 2400s = 40m max wait
Zack Williamsabd5d862016-04-26 15:26:47 -070079- name: Wait for juju services to start
80 action: command juju status --format=summary
81 register: juju_summary
82 until: juju_summary.stdout.find("pending:") == -1
Zack Williams70d512c2016-06-02 12:33:14 -070083 retries: 160
Zack Williamsabd5d862016-04-26 15:26:47 -070084 delay: 15
85
Zack Williams709f11b2016-03-17 14:29:51 -070086- name: Create admin-openrc.sh credentials file
87 template:
88 src=admin-openrc.sh.j2
89 dest={{ ansible_user_dir }}/admin-openrc.sh
90
Zack Williams17508be2016-05-31 21:52:35 -070091
Zack Williams709f11b2016-03-17 14:29:51 -070092- name: Copy nova-cloud-controller CA certificate to head
93 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 -040094 register: result
95 until: result | success
Zack Williamsb364ef52016-08-17 17:18:22 -070096 retries: 40
Zack Williams6f5a6e72016-08-10 17:45:27 -070097 delay: 15
Zack Williams709f11b2016-03-17 14:29:51 -070098
Zack Williams008ce252016-04-30 14:39:15 -070099- name: Copy cert to system location
Zack Williams709f11b2016-03-17 14:29:51 -0700100 become: yes
Zack Williams008ce252016-04-30 14:39:15 -0700101 command: cp {{ ansible_user_dir }}/keystone_juju_ca_cert.crt /usr/local/share/ca-certificates
Zack Williams5028fb42016-06-01 14:52:29 -0700102
103- name: update-ca-certificates
104 become: yes
105 command: update-ca-certificates
Zack Williams709f11b2016-03-17 14:29:51 -0700106
Zack Williamsd8b8f472016-05-16 22:40:30 -0700107- name: Move cert to all service VM's
108 command: ansible services -b -u ubuntu -m copy -a "src={{ ansible_user_dir }}/keystone_juju_ca_cert.crt dest=/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt owner=root group=root mode=0644"
Zack Williams5a2b62d2016-04-28 07:55:18 -0700109
Zack Williamsd8b8f472016-05-16 22:40:30 -0700110- name: update-ca-certificates in service VM's
111 command: ansible services -b -u ubuntu -m command -a "update-ca-certificates"
Zack Williams3dfe6af2016-04-30 11:37:09 -0700112