blob: 80750131b19eb91502f4928c86fa30345c9c9aff [file] [log] [blame]
Zack Williamsf40f3ce2016-03-01 22:01:28 -07001---
2# roles/juju-openstack-config/main/tasks.yml
3
Zack Williams709f11b2016-03-17 14:29:51 -07004- name: add compute nodes
5 command: juju add-machine ssh:ubuntu@{{ item }}
6 with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}"
Zack Williams99dcc1c2016-04-14 07:02:57 -07007 register: added_compute_nodes
Zack Williamsf40f3ce2016-03-01 22:01:28 -07008
Zack Williams709f11b2016-03-17 14:29:51 -07009# 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 Williams99dcc1c2016-04-14 07:02:57 -070011 when: added_compute_nodes
Zack Williams709f11b2016-03-17 14:29:51 -070012 juju_facts:
Zack Williamsf40f3ce2016-03-01 22:01:28 -070013
Zack Williams709f11b2016-03-17 14:29:51 -070014# 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 Williams99dcc1c2016-04-14 07:02:57 -070019 register: added_first_nova_compute
Zack Williamsf40f3ce2016-03-01 22:01:28 -070020
Zack Williams709f11b2016-03-17 14:29:51 -070021# 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 Williams99dcc1c2016-04-14 07:02:57 -070024 when: added_first_nova_compute
Zack Williams709f11b2016-03-17 14:29:51 -070025
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 Williams709f11b2016-03-17 14:29:51 -070030- 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 Williamsf40f3ce2016-03-01 22:01:28 -070039- 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 Williams709f11b2016-03-17 14:29:51 -070050 command: ansible nova-cloud-controller-1 -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Zack Williamsf40f3ce2016-03-01 22:01:28 -070051