blob: 5782795f943acbc08504cb95f4f40f6cfe8bd339 [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
50 src: "{{ item.source_path | replace('~', ansible_env.HOME, 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 Baviera6cffe12017-03-15 17:33:42 -040067- name: Make local images directory
68 delegate_to: localhost
Zack Williamsc6ff6b32017-02-10 16:35:29 -070069 become: yes
70 file:
Andy Baviera6cffe12017-03-15 17:33:42 -040071 path: "{{ image_dir }}"
Zack Williamsc6ff6b32017-02-10 16:35:29 -070072 state: directory
73 mode: 0755
74 owner: "{{ ansible_user_id }}"
75 group: "{{ ansible_user_gid }}"
76
Zack Williamsa2763112017-01-03 11:38:38 -070077- name: Download Glance VM images
Andy Baviera6cffe12017-03-15 17:33:42 -040078 when: use_openstack
79 delegate_to: localhost
Zack Williamsa2763112017-01-03 11:38:38 -070080 get_url:
81 url: "{{ item.url }}"
82 checksum: "{{ item.checksum }}"
Andy Baviera6cffe12017-03-15 17:33:42 -040083 dest: "{{ image_dir }}/{{ item.name }}.qcow2"
Zack Williamsc6ff6b32017-02-10 16:35:29 -070084 with_items: "{{ xos_images }}"
85
86- name: Copy Glance VM images to profile directory
Andy Baviera6cffe12017-03-15 17:33:42 -040087 when: use_openstack
Zack Williamsc6ff6b32017-02-10 16:35:29 -070088 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -040089 src: "{{ image_dir }}/{{ item.name }}.qcow2"
Zack Williamsa2763112017-01-03 11:38:38 -070090 dest: "{{ cord_profile_dir }}/images/{{ item.name }}.qcow2"
91 with_items: "{{ xos_images }}"
92
93- name: Copy over commonly used and utility TOSCA files
94 copy:
95 src: "{{ item }}"
96 dest: "{{ cord_profile_dir }}/{{ item }}"
97 with_items:
98 - fixtures.yaml
99 - enable-onboarding.yaml
100 - disable-onboarding.yaml
101
102- name: Create templated XOS configuration files
103 template:
104 src: "{{ item }}.j2"
105 dest: "{{ cord_profile_dir }}/{{ item }}"
106 mode: 0644
107 with_items:
108 - xos_common_config
109 - deployment.yaml
110 - xos.yaml
111 - xos-bootstrap-docker-compose.yaml
Scott Baker5ca4bd12017-02-10 15:17:06 -0800112 - onboard-chameleon.yaml
Matteo Scandolo6050fda2017-02-16 13:01:52 -0800113 - onboard-gui-extensions-store.yaml
Scott Baker970f24b2017-02-13 14:16:40 -0800114 - onboard-xos-gui.yaml
115 - onboard-xos-rest-gw.yaml
116 - gateway-config.yml
Matteo Scandolo667334f2017-02-26 10:58:08 -0800117 - style.config.js
118 - app.config.js
Andy Baviera6cffe12017-03-15 17:33:42 -0400119 - Dockerfile.xos
120 - xos-gui-extensions-onboard.yml
121 - xos-gui-extensions.yml
Zack Williamsa2763112017-01-03 11:38:38 -0700122
123- name: Create profile specific templated TOSCA config files
124 template:
125 src: "{{ item }}.j2"
126 dest: "{{ cord_profile_dir }}/{{ item }}"
127 with_items: "{{ xos_tosca_config_templates }}"
128
129- name: Create profile specific templated non-TOSCA files
130 template:
131 src: "{{ item }}.j2"
132 dest: "{{ cord_profile_dir }}/{{ item }}"
133 with_items: "{{ xos_other_templates }}"
134
Andy Baviera6cffe12017-03-15 17:33:42 -0400135- name: Copy node key
136 when: not on_maas and use_openstack
Zack Williamsa2763112017-01-03 11:38:38 -0700137 copy:
Andy Baviera6cffe12017-03-15 17:33:42 -0400138 src: "{{ ansible_user_dir }}/.ssh/id_rsa"
139 dest: "{{ item }}/node_key"
140 owner: "{{ ansible_user }}"
Zack Williams2a5f6862017-02-09 16:39:52 -0700141 mode: 0600
Andy Bavier1ff4b482017-03-24 09:20:36 -0400142 remote_src: True
Andy Baviera6cffe12017-03-15 17:33:42 -0400143 with_items:
144 - "{{ ansible_user_dir }}"
145 - "{{ cord_profile_dir }}"
146
147- name: Copy node key (MaaS)
148 when: on_maas and use_openstack
149 become: yes
150 copy:
151 src: "{{ maas_node_key }}"
152 dest: "{{ item }}/node_key"
153 owner: "{{ ansible_user }}"
154 mode: 0600
155 remote_src: True
156 with_items:
157 - "{{ ansible_user_dir }}"
158 - "{{ cord_profile_dir }}"