blob: 7d6d1b0f7983ac02b7f2f85f4ff964d3fa562e23 [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() ) }}"
7 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
11 when: added-compute-nodes
12 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() ) }}"
19 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:
24 when: added-first-nova-compute
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
30# added this to openstack.cfg
31# - name: Have nova-compute use KVM as its virt-type
32# command: juju set nova-compute virt-type=kvm
33
34- name: Create relations to compute
35 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
36 register: compute_relation
37 failed_when: "compute_relation|failed and 'relation already exists' not in compute_relation.stderr"
38 with_subelements:
39 - "{{ compute_relations }}"
40 - relations
41
42# need to ansible-ify these
Zack Williamsf40f3ce2016-03-01 22:01:28 -070043- name: Copy credentials file to nova-cloud-controller
44 command: "scp {{ ansible_user_dir }}/admin-openrc.sh ubuntu@nova-cloud-controller:"
45
46- name: Copy network setup script
47 become: yes
48 copy:
49 src=network-setup.sh
50 dest=/usr/local/src/network-setup.sh
51 mode=0644 owner=root
52
53- name: Run network setup script
Zack Williams709f11b2016-03-17 14:29:51 -070054 command: ansible nova-cloud-controller-1 -m script -u ubuntu -a "/usr/local/src/network-setup.sh"
Zack Williamsf40f3ce2016-03-01 22:01:28 -070055
Zack Williamsf40f3ce2016-03-01 22:01:28 -070056