blob: 9b391079eb4245db6029798146b0f9ced1f10285 [file] [log] [blame]
Zack Williamsa2763112017-01-03 11:38:38 -07001---
2# cord-profile/tasks/main.yml
3# Constructs a CORD service profile directory and configuration files
4
Andy Baviera6cffe12017-03-15 17:33:42 -04005- name: Create and copy XOS admin password
6 copy:
7 content: "{{ xos_admin_pass }}"
8 dest: "{{ cord_dir }}/build/platform-install/credentials/{{ xos_admin_user }}"
9
Zack Williamsa2763112017-01-03 11:38:38 -070010- name: Create cord_profile directory
11 become: yes
12 file:
13 path: "{{ cord_profile_dir }}"
14 state: directory
15 mode: 0755
16 owner: "{{ ansible_user_id }}"
17 group: "{{ ansible_user_gid }}"
18
Zack Williams2478b302017-02-14 10:42:55 -070019- name: Create cord_profile/profile_name with the name of the profile
20 copy:
21 dest: "{{ cord_profile_dir }}/profile_name"
22 content: "{{ cord_profile }}"
23 mode: 0644
24
Zack Williamsa2763112017-01-03 11:38:38 -070025- name: Create subdirectories inside cord_profile directory
26 file:
27 path: "{{ cord_profile_dir }}/{{ item }}"
28 state: directory
29 mode: 0755
30 with_items:
31 - key_import
32 - onboarding-docker-compose
33 - images
34
Andy Bavier1ff4b482017-03-24 09:20:36 -040035# *** This should be revisited. ***
36# Currently the key pair is generated on the head node by the
37# "prep" role in the "maas" repo, invoked during the "deployBase" Gradle task.
38# The keys should probably be generated earlier, in the corddev VM, and copied over.
39# The /opt/credentials directory might be a good place to keep the generated keys.
40#
41# Ensure a keypair exists in case we're not running on MaaS.
42- name: Ensure keypair
43 user:
44 name: "{{ ansible_user_id }}"
45 generate_ssh_key: yes
46
Zack Williamsa2763112017-01-03 11:38:38 -070047- name: Copy ssh keys to key_import directory
48 copy:
Andy Bavier4b490d72017-03-25 07:59:21 -040049 # 'expanduser' won't work below, it expands on control machine
Andy Bavier53b03f62017-03-25 11:42:23 -040050 src: "{{ item.source_path | replace('~', ansible_user_dir, 1) }}"
Zack Williamsa2763112017-01-03 11:38:38 -070051 dest: "{{ cord_profile_dir }}/key_import/{{ item.name }}"
52 mode: 0600
Andy Bavier1ff4b482017-03-24 09:20:36 -040053 remote_src: True
Zack Williamsa2763112017-01-03 11:38:38 -070054 with_items: "{{ xos_service_sshkeys }}"
55
Andy Baviera6cffe12017-03-15 17:33:42 -040056- name: Copy cert chain and core api key and cert
Andy Bavierf0b5d7d2017-03-15 16:19:03 -040057 copy:
58 src: "{{ pki_dir }}/{{ item }}"
59 dest: "{{ cord_profile_dir }}/{{ item }}"
60 mode: 0600
Andy Baviera6cffe12017-03-15 17:33:42 -040061 remote_src: True
Andy Bavierf0b5d7d2017-03-15 16:19:03 -040062 with_items:
63 - core_api_key.pem
64 - core_api_cert.pem
Andy Baviera6cffe12017-03-15 17:33:42 -040065 - im_cert_chain.pem
Andy Bavierf0b5d7d2017-03-15 16:19:03 -040066
Andy Bavier53b03f62017-03-25 11:42:23 -040067- name: Get localhost facts (to get local uid and gid)
68 setup:
69 delegate_to: localhost
70 delegate_facts: True
71
Andy Baviera6cffe12017-03-15 17:33:42 -040072- name: Make local images directory
73 delegate_to: localhost
Zack Williamsc6ff6b32017-02-10 16:35:29 -070074 become: yes
75 file:
Andy Baviera6cffe12017-03-15 17:33:42 -040076 path: "{{ image_dir }}"
Zack Williamsc6ff6b32017-02-10 16:35:29 -070077 state: directory
78 mode: 0755
Andy Bavier53b03f62017-03-25 11:42:23 -040079 owner: "{{ hostvars['localhost']['ansible_user_id'] }}"
80 group: "{{ hostvars['localhost']['ansible_user_gid'] }}"
Zack Williamsc6ff6b32017-02-10 16:35:29 -070081
Zack Williamsa2763112017-01-03 11:38:38 -070082- name: Download Glance VM images
Andy Baviera6cffe12017-03-15 17:33:42 -040083 when: use_openstack
84 delegate_to: localhost
Zack Williamsa2763112017-01-03 11:38:38 -070085 get_url:
86 url: "{{ item.url }}"
87 checksum: "{{ item.checksum }}"
Andy Baviera6cffe12017-03-15 17:33:42 -040088 dest: "{{ image_dir }}/{{ item.name }}.qcow2"
Zack Williamsc6ff6b32017-02-10 16:35:29 -070089 with_items: "{{ xos_images }}"
Zack Williams275e48b2017-03-24 12:16:00 -070090 register: glance_vm_result
91 until: glance_vm_result|success
92 retries: 5
93 delay: 10
Zack Williamsc6ff6b32017-02-10 16:35:29 -070094
95- name: Copy Glance VM images to profile directory
Andy Baviera6cffe12017-03-15 17:33:42 -040096 when: use_openstack
Zack Williamsc6ff6b32017-02-10 16:35:29 -070097 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -040098 src: "{{ image_dir }}/{{ item.name }}.qcow2"
Zack Williamsa2763112017-01-03 11:38:38 -070099 dest: "{{ cord_profile_dir }}/images/{{ item.name }}.qcow2"
100 with_items: "{{ xos_images }}"
101
102- name: Copy over commonly used and utility TOSCA files
103 copy:
104 src: "{{ item }}"
105 dest: "{{ cord_profile_dir }}/{{ item }}"
106 with_items:
107 - fixtures.yaml
108 - enable-onboarding.yaml
109 - disable-onboarding.yaml
110
111- name: Create templated XOS configuration files
112 template:
113 src: "{{ item }}.j2"
114 dest: "{{ cord_profile_dir }}/{{ item }}"
115 mode: 0644
116 with_items:
117 - xos_common_config
118 - deployment.yaml
119 - xos.yaml
Scott Baker970f24b2017-02-13 14:16:40 -0800120 - gateway-config.yml
Matteo Scandolo667334f2017-02-26 10:58:08 -0800121 - style.config.js
122 - app.config.js
Andy Baviera6cffe12017-03-15 17:33:42 -0400123 - Dockerfile.xos
Andy Baviera6cffe12017-03-15 17:33:42 -0400124 - xos-gui-extensions.yml
Andy Bavier9e7d54a2017-04-17 11:37:02 -0400125 - docker-compose.yml
Zack Williamsa2763112017-01-03 11:38:38 -0700126
127- name: Create profile specific templated TOSCA config files
128 template:
129 src: "{{ item }}.j2"
130 dest: "{{ cord_profile_dir }}/{{ item }}"
131 with_items: "{{ xos_tosca_config_templates }}"
132
133- name: Create profile specific templated non-TOSCA files
134 template:
135 src: "{{ item }}.j2"
136 dest: "{{ cord_profile_dir }}/{{ item }}"
137 with_items: "{{ xos_other_templates }}"
138
Andy Baviera6cffe12017-03-15 17:33:42 -0400139- name: Copy node key
140 when: not on_maas and use_openstack
Zack Williamsa2763112017-01-03 11:38:38 -0700141 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -0400142 src: "{{ ansible_user_dir }}/.ssh/id_rsa"
143 dest: "{{ item }}/node_key"
144 owner: "{{ ansible_user }}"
Zack Williams2a5f6862017-02-09 16:39:52 -0700145 mode: 0600
Andy Bavier1ff4b482017-03-24 09:20:36 -0400146 remote_src: True
Andy Baviera6cffe12017-03-15 17:33:42 -0400147 with_items:
148 - "{{ ansible_user_dir }}"
149 - "{{ cord_profile_dir }}"
150
151- name: Copy node key (MaaS)
152 when: on_maas and use_openstack
153 become: yes
154 copy:
155 src: "{{ maas_node_key }}"
156 dest: "{{ item }}/node_key"
157 owner: "{{ ansible_user }}"
158 mode: 0600
159 remote_src: True
160 with_items:
161 - "{{ ansible_user_dir }}"
162 - "{{ cord_profile_dir }}"