blob: cf52f826e8ad23bc18f6c1f72ea96002cab979bc [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 }}"
90
91- name: Copy Glance VM images to profile directory
Andy Baviera6cffe12017-03-15 17:33:42 -040092 when: use_openstack
Zack Williamsc6ff6b32017-02-10 16:35:29 -070093 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -040094 src: "{{ image_dir }}/{{ item.name }}.qcow2"
Zack Williamsa2763112017-01-03 11:38:38 -070095 dest: "{{ cord_profile_dir }}/images/{{ item.name }}.qcow2"
96 with_items: "{{ xos_images }}"
97
98- name: Copy over commonly used and utility TOSCA files
99 copy:
100 src: "{{ item }}"
101 dest: "{{ cord_profile_dir }}/{{ item }}"
102 with_items:
103 - fixtures.yaml
104 - enable-onboarding.yaml
105 - disable-onboarding.yaml
106
107- name: Create templated XOS configuration files
108 template:
109 src: "{{ item }}.j2"
110 dest: "{{ cord_profile_dir }}/{{ item }}"
111 mode: 0644
112 with_items:
113 - xos_common_config
114 - deployment.yaml
115 - xos.yaml
116 - xos-bootstrap-docker-compose.yaml
Scott Baker5ca4bd12017-02-10 15:17:06 -0800117 - onboard-chameleon.yaml
Matteo Scandolo6050fda2017-02-16 13:01:52 -0800118 - onboard-gui-extensions-store.yaml
Scott Baker970f24b2017-02-13 14:16:40 -0800119 - onboard-xos-gui.yaml
120 - onboard-xos-rest-gw.yaml
121 - gateway-config.yml
Matteo Scandolo667334f2017-02-26 10:58:08 -0800122 - style.config.js
123 - app.config.js
Andy Baviera6cffe12017-03-15 17:33:42 -0400124 - Dockerfile.xos
125 - xos-gui-extensions-onboard.yml
126 - xos-gui-extensions.yml
Zack Williamsa2763112017-01-03 11:38:38 -0700127
128- name: Create profile specific templated TOSCA config files
129 template:
130 src: "{{ item }}.j2"
131 dest: "{{ cord_profile_dir }}/{{ item }}"
132 with_items: "{{ xos_tosca_config_templates }}"
133
134- name: Create profile specific templated non-TOSCA files
135 template:
136 src: "{{ item }}.j2"
137 dest: "{{ cord_profile_dir }}/{{ item }}"
138 with_items: "{{ xos_other_templates }}"
139
Andy Baviera6cffe12017-03-15 17:33:42 -0400140- name: Copy node key
141 when: not on_maas and use_openstack
Zack Williamsa2763112017-01-03 11:38:38 -0700142 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -0400143 src: "{{ ansible_user_dir }}/.ssh/id_rsa"
144 dest: "{{ item }}/node_key"
145 owner: "{{ ansible_user }}"
Zack Williams2a5f6862017-02-09 16:39:52 -0700146 mode: 0600
Andy Bavier1ff4b482017-03-24 09:20:36 -0400147 remote_src: True
Andy Baviera6cffe12017-03-15 17:33:42 -0400148 with_items:
149 - "{{ ansible_user_dir }}"
150 - "{{ cord_profile_dir }}"
151
152- name: Copy node key (MaaS)
153 when: on_maas and use_openstack
154 become: yes
155 copy:
156 src: "{{ maas_node_key }}"
157 dest: "{{ item }}/node_key"
158 owner: "{{ ansible_user }}"
159 mode: 0600
160 remote_src: True
161 with_items:
162 - "{{ ansible_user_dir }}"
163 - "{{ cord_profile_dir }}"