Initial commit
[ta/infra-ansible.git] / roles / bootstrap-host / tasks / prepare_aio_config.yml
1 ---
2 # Copyright 2015, Rackspace US, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16
17 - name: Create the required deployment directories
18   file:
19     path: "{{ item }}"
20     state: directory
21     mode: u=rwx,g=rwx,o=rwx
22   with_items:
23     - "/etc/openstack_deploy/"
24     - "/etc/openstack_deploy/conf.d"
25   tags:
26     - create-directories
27
28
29 - name: Deploy user conf.d configuration
30   config_template:
31     src: "{{ item.path | default(bootstrap_host_aio_config_path ~ '/conf.d') }}/{{ item.name }}"
32     dest: "/etc/openstack_deploy/conf.d/{{ item.name | regex_replace('.aio$', '') }}"
33     config_overrides: "{{ item.override | default({}) }}"
34     config_type: "yaml"
35   with_items: "{{ openstack_confd_entries | default([]) }}"
36   tags:
37     - deploy-confd
38
39 - name: Deploy openstack_user_config
40   copy:
41     src: "{{ bootstrap_host_aio_config_path }}/{{ bootstrap_host_aio_config_name }}"
42     dest: "/etc/openstack_deploy/openstack_user_config.yml"
43   tags:
44     - deploy-openstack-user-config
45
46 - name: Deploy user_secrets file
47   config_template:
48     src: "{{ bootstrap_host_aio_config_path }}/user_secrets.yml"
49     dest: "/etc/openstack_deploy/{{ bootstrap_host_user_secrets_filename }}"
50     config_overrides: "{{ user_secrets_overrides | default({}) }}"
51     config_type: "yaml"
52   tags:
53     - deploy-user-secrets
54
55 - name: Generate any missing values in user_secrets
56   command: "{{ bootstrap_host_aio_script_path }}/pw-token-gen.py --file /etc/openstack_deploy/{{ bootstrap_host_user_secrets_filename }}"
57   changed_when: false
58   tags:
59     - generate_secrets
60
61 - name: Detect whether the host is an OpenStack-CI host
62   stat:
63     path: /etc/nodepool
64   register: nodepool_dir
65
66 - name: Set the UCA repository URL in OpenStack-CI
67   set_fact:
68     uca_apt_repo_url: "{{ bootstrap_host_ubuntu_repo | netorigin }}/ubuntu-cloud-archive"
69   when:
70     - nodepool_dir.stat.exists
71     - bootstrap_host_ubuntu_repo is defined
72
73 - name: Set the package cache timeout to 60 mins in OpenStack-CI
74   set_fact:
75     cache_timeout: 3600
76   when:
77     - cache_timeout is not defined
78     - nodepool_dir.stat.exists
79
80 - name: Determine if the host has a global pip config file
81   stat:
82     path: /etc/pip.conf
83   register: pip_conf_file
84
85 - name: Determine the fastest available OpenStack-Infra wheel mirror
86   command: "{{ bootstrap_host_aio_script_path }}/fastest-infra-wheel-mirror.py"
87   register: fastest_wheel_mirror
88   when: not pip_conf_file.stat.exists
89
90 - name: Set repo_build_pip_extra_indexes fact
91   set_fact:
92     repo_build_pip_extra_indexes: "{{ fastest_wheel_mirror.stdout_lines }}"
93   when: not pip_conf_file.stat.exists
94
95 - name: Check whether the host has a git cache
96   stat:
97     path: /opt/git/openstack
98   register: _local_git_cache
99
100 - name: Set repo_build_git_cache fact
101   set_fact:
102     repo_build_git_cache: /opt/git/openstack
103   when: _local_git_cache.stat.exists
104
105 - name: Copy example user_variables
106   copy:
107     src: "{{ bootstrap_host_aio_config_path }}/{{ bootstrap_host_user_variables_filename }}"
108     dest: "/etc/openstack_deploy/user_variables.yml"
109
110 - name: Create /etc/openstack_deploy/env.d/ directories
111   file:
112     path: "/etc/openstack_deploy/env.d/"
113     state: directory
114   when: bootstrap_env_file is defined
115
116 - name: Copy example user_variables
117   copy:
118     src: "{{ bootstrap_env_file }}"
119     dest: "/etc/openstack_deploy/env.d/"
120   when: bootstrap_env_file is defined
121
122 - name: Add user_conf_files to contain the list of files to copy into containers
123   file:
124     path: /etc/openstack_deploy/user_conf_files.yml
125     state: touch
126   when: pip_conf_file.stat.exists
127   tags:
128     - container-conf-files
129
130 - name: Ensure that the first line in user_conf_files is correct
131   lineinfile:
132     dest: /etc/openstack_deploy/user_conf_files.yml
133     line: "---"
134     insertbefore: BOF
135   when: pip_conf_file.stat.exists
136   tags:
137     - container-conf-files
138
139 - name: Ensure that the second line in user_conf_files is correct
140   lineinfile:
141     dest: /etc/openstack_deploy/user_conf_files.yml
142     line: "lxc_container_cache_files:"
143     insertafter: "^---"
144   when: pip_conf_file.stat.exists
145   tags:
146     - container-conf-files
147
148 - name: Add the dict to copy the global pip config file into user_conf_files
149   lineinfile:
150     dest: /etc/openstack_deploy/user_conf_files.yml
151     line: " - { src: '/etc/pip.conf', dest: '/etc/pip.conf' }"
152   when: pip_conf_file.stat.exists
153   tags:
154     - container-conf-files