Initial commit
[ta/infra-ansible.git] / roles / bootstrap-host / tasks / main.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 # Before we do anything, check the minimum requirements
17 - include: check-requirements.yml
18   tags:
19     - check-requirements
20
21 # We will look for the most specific variable files first and eventually
22 # end up with the least-specific files.
23 - name: Gather variables for each operating system
24   include_vars: "{{ item }}"
25   with_first_found:
26     - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
27     - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
28     - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
29     - "{{ ansible_distribution | lower }}.yml"
30     - "{{ ansible_os_family | lower }}.yml"
31   tags:
32     - always
33
34 - name: Create the required directories
35   file:
36     path: "{{ item }}"
37     state: directory
38     mode: u=rwx,g=rwx,o=rwx
39   with_items:
40     - "/openstack"
41   tags:
42     - create-directories
43
44 # Create sudo user
45 - include: create_sudo_user.yml
46   tags:
47     - create-sudo-user
48
49 - include: install_packages.yml
50   tags:
51     - install-packages
52
53 # Prepare the data disk, if one is provided
54 - include: prepare_data_disk.yml
55   when: bootstrap_host_data_disk_device != None
56   tags:
57     - prepare-data-disk
58
59 # Prepare the swap space loopback disk
60 # This is only necessary if there isn't swap already
61 - include: prepare_loopback_swap.yml
62   when:
63     - ansible_swaptotal_mb < 1
64   tags:
65     - prepare-loopback-swap
66
67 # Prepare the Cinder LVM VG loopback disk
68 # This is only necessary if bootstrap_host_loopback_cinder is set to yes
69 - include: prepare_loopback_cinder.yml
70   when:
71     - bootstrap_host_loopback_cinder | bool
72   tags:
73     - prepare-loopback-cinder
74
75 # Prepare the Nova instance storage loopback disk
76 - include: prepare_loopback_nova.yml
77   when:
78     - bootstrap_host_loopback_nova | bool
79   tags:
80     - prepare-loopback-nova
81
82 # Prepare the Swift data storage loopback disks
83 - include: prepare_loopback_swift.yml
84   when:
85     - bootstrap_host_loopback_swift | bool
86   tags:
87     - prepare-loopback-swift
88
89 # Prepare the Ceph cluster UUID and loopback disks
90 - include: prepare_ceph.yml
91   when:
92     - bootstrap_host_ceph | bool
93   tags:
94     - prepare-ceph
95
96 # Prepare the network interfaces
97 - include: prepare_networking.yml
98   tags:
99     - prepare-networking
100
101 # Prepare the network interfaces using os-net-config
102 - include: prepare_os_net_config.yml
103   tags:
104     - prepare-os-net-config
105
106 # Ensure that there are both private and public ssh keys for root
107 - include: prepare_ssh_keys.yml
108   tags:
109     - prepare-ssh-keys
110
111 # Put the OpenStack-Ansible configuration for an All-In-One on the host
112 - include: prepare_aio_config.yml
113   when: bootstrap_host_aio_config | bool
114   tags:
115     - prepare-aio-config
116
117 # Change owner for /etc/openstack_deploy
118 - name: Set permissions for /etc/openstack_deploy
119   file:
120     path: "/etc/openstack_deploy"
121     owner: "{{ sudo_user }}"
122     group: "{{ sudo_user }}"
123     recurse: yes
124     mode: 0700
125
126 - name: 2nd phase, set different permissions only for /etc/openstack_deploy -directory
127   file:
128     path: "/etc/openstack_deploy"
129     owner: "{{ sudo_user }}"
130     group: "{{ sudo_user }}"
131     recurse: no
132     mode: u=rwX,g=rX,o=rX
133
134 # Change owner of /etc/userconfig
135 - name: Set permissions for /etc/userconfig
136   file:
137     path: "/etc/userconfig"
138     owner: "{{ sudo_user }}"
139     group: "{{ sudo_user }}"
140     recurse: yes
141     mode: 0700