blob: bf40c73fa5d9fc78c79e9f4761a51215f7760bfd [file] [log] [blame]
Zack Williams573bafc2016-02-26 16:35:42 -07001---
2# roles/juju-setup/main/tasks.yml
3
Zack Williams0df6f2c2016-02-29 14:48:52 -07004- name: create Virtual Machines with uvt-kvm
5 shell: uvt-kvm create {{ item.name }} --cpu={{ item.cpu }} --memory={{ item.memMB }} --disk={{ item.diskGB }}; \
6 uvt-kvm wait --insecure {{ item.name }}
7 creates=/var/lib/uvtool/libvirt/images/{{ item.name }}.qcow
8 with_items: head_vm_list
9
10- name: discover VM IP addresses
11 shell: uvt-kvm ip {{ item.name }}
12 with_items: head_vm_list
13 register: vm_ip
14
15- name: Create /etc/hosts with VM IP addresses
16 become: yes
17 template:
18 src=hosts.j2
19 dest=/etc/hosts
20
21- name: Create /etc/ansible/hosts file
22 become: yes
23 template:
24 src=ansible_hosts.j2
25 dest=/etc/ansible/hosts
26
Zack Williams573bafc2016-02-26 16:35:42 -070027- name: Verify that we can log into every VM
28 command: ansible services -m ping -u ubuntu
29
30- name: Initialize Juju
31 command: juju generate-config
Zack Williams823d5292016-02-29 10:31:17 -070032 creates={{ ansible_user_dir }}/.juju/environments.yaml
Zack Williams573bafc2016-02-26 16:35:42 -070033
Zack Williams823d5292016-02-29 10:31:17 -070034- name: Create Juju config file from template
Zack Williams573bafc2016-02-26 16:35:42 -070035 template:
Zack Williams823d5292016-02-29 10:31:17 -070036 src=environments.yaml.j2
37 dest={{ ansible_user_dir }}/.juju/environments.yaml
Zack Williams573bafc2016-02-26 16:35:42 -070038
39- name: Bootstrap Juju
40 command: juju bootstrap
Zack Williams823d5292016-02-29 10:31:17 -070041 creates={{ ansible_user_dir }}/.juju/environments/manual.jenv
Zack Williams573bafc2016-02-26 16:35:42 -070042
Zack Williams0df6f2c2016-02-29 14:48:52 -070043- name: Create openstack.cfg for Juju from template
Zack Williams573bafc2016-02-26 16:35:42 -070044 become: yes
Zack Williams0df6f2c2016-02-29 14:48:52 -070045 template:
46 src=openstack.cfg.j2
47 dest={{ openstack_cfg_path }}
Zack Williams573bafc2016-02-26 16:35:42 -070048
Zack Williams0df6f2c2016-02-29 14:48:52 -070049# Code for this is in library/juju_facts.py
Zack Williams32e12fb2016-02-29 10:25:59 -070050- name: Obtain Juju Facts
51 juju_facts:
Zack Williams573bafc2016-02-26 16:35:42 -070052
Zack Williams823d5292016-02-29 10:31:17 -070053# For setwise operations on desired vs Juju state:
Zack Williams0df6f2c2016-02-29 14:48:52 -070054# list of VM names in head_vm_list dict: head_vm_list | map(attribute='name') | list
Zack Williams32e12fb2016-02-29 10:25:59 -070055# list of active juju_machines names: juju_machines.keys()
Zack Williams823d5292016-02-29 10:31:17 -070056# list of active juju_services names: juju_services.keys()
Zack Williams573bafc2016-02-26 16:35:42 -070057
Zack Williams9cdf8622016-02-26 22:42:50 -070058- name: Add machines to Juju
Zack Williams32e12fb2016-02-29 10:25:59 -070059 command: "juju add-machine ssh:{{ item }}"
Zack Williams0df6f2c2016-02-29 14:48:52 -070060 with_items: "{{ head_vm_list | map(attribute='name') | list | difference( juju_machines.keys() ) }}"
61
62- name: Deploy services that are hosted in their own VM
63 command: "juju deploy {{ item }} --to {{ juju_machines[item]['machine_id'] }} --config={{ openstack_cfg_path }}"
64 with_items: "{{ vm_service_list | difference( juju_services.keys() ) }}"
65
66- name: Deploy mongodb to ceilometer VM
67 command: "juju deploy mongodb --to {{ juju_machines['ceilometer']['machine_id'] }} --config={{ openstack_cfg_path }}"
68 when: juju_services['mongodb'] is undefined
69
70- name: Deploy services that don't have their own VM
71 command: "juju deploy {{ item }} --config={{ openstack_cfg_path }}"
72 with_items: "{{ standalone_service_list | difference( juju_services.keys() ) }}"
Zack Williams32e12fb2016-02-29 10:25:59 -070073