Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 1 | --- |
| 2 | # roles/juju-openstack-config/main/tasks.yml |
| 3 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 4 | - name: add compute nodes |
| 5 | command: juju add-machine ssh:ubuntu@{{ item }} |
| 6 | with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}" |
Zack Williams | 99dcc1c | 2016-04-14 07:02:57 -0700 | [diff] [blame] | 7 | register: added_compute_nodes |
Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 8 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 9 | # run this again, so add-machine items will be in the juju_compute_nodes list |
| 10 | - name: Obtain Juju Facts after adding compute nodes |
Zack Williams | 99dcc1c | 2016-04-14 07:02:57 -0700 | [diff] [blame] | 11 | when: added_compute_nodes |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 12 | juju_facts: |
Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 13 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 14 | # the crazy [ ] in the with-items is so that jinja compares arrays of strings, |
| 15 | # rather than strings of characters |
| 16 | - name: add-unit nova-compute to first compute node |
| 17 | command: "juju deploy nova-compute --to {{ juju_machines[item]['machine_id'] }} --config={{ openstack_cfg_path }}" |
| 18 | with_items: "{{ [ groups['compute'][0] ] | difference( juju_compute_nodes.keys() ) }}" |
Zack Williams | 99dcc1c | 2016-04-14 07:02:57 -0700 | [diff] [blame] | 19 | register: added_first_nova_compute |
Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 20 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 21 | # run this again, so first nova compute will be in the juju_compute_nodes list |
| 22 | - name: Obtain Juju Facts nova-compute deploy |
| 23 | juju_facts: |
Zack Williams | 99dcc1c | 2016-04-14 07:02:57 -0700 | [diff] [blame] | 24 | when: added_first_nova_compute |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 25 | |
| 26 | - name: add-unit nova-compute to other compute nodes |
| 27 | command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}" |
| 28 | with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}" |
| 29 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 30 | - name: Create relations to compute |
| 31 | command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'" |
| 32 | register: compute_relation |
| 33 | failed_when: "compute_relation|failed and 'relation already exists' not in compute_relation.stderr" |
| 34 | with_subelements: |
| 35 | - "{{ compute_relations }}" |
| 36 | - relations |
| 37 | |
| 38 | # need to ansible-ify these |
Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 39 | - name: Copy credentials file to nova-cloud-controller |
| 40 | command: "scp {{ ansible_user_dir }}/admin-openrc.sh ubuntu@nova-cloud-controller:" |
| 41 | |
| 42 | - name: Copy network setup script |
| 43 | become: yes |
| 44 | copy: |
| 45 | src=network-setup.sh |
| 46 | dest=/usr/local/src/network-setup.sh |
| 47 | mode=0644 owner=root |
| 48 | |
| 49 | - name: Run network setup script |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 50 | command: ansible nova-cloud-controller-1 -m script -u ubuntu -a "/usr/local/src/network-setup.sh" |
Zack Williams | f40f3ce | 2016-03-01 22:01:28 -0700 | [diff] [blame] | 51 | |