/
pre-install.yml
137 lines (119 loc) · 3.38 KB
/
pre-install.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
# NOTE: raw install is required to support cloud images which do not have python installed
- name: "Install python2 and python-simplejson"
become: True
raw: "yum install -y python python-simplejson || (apt-get update && apt-get install -y python2.7 python-simplejson)"
- name: Gather facts
setup:
- name: Ensure localhost in /etc/hosts
lineinfile:
dest: /etc/hosts
regexp: "^127.0.0.1.*"
line: "127.0.0.1 localhost"
state: present
become: True
when: customize_etc_hosts | bool
- name: Generate /etc/hosts for all of the nodes
blockinfile:
dest: /etc/hosts
marker: "# {mark} ANSIBLE GENERATED HOSTS"
block: |
{% for host in groups['all'] %}
{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
{% endfor %}
become: True
when: customize_etc_hosts | bool
- name: Ensure sudo group is present
group: name=sudo state=present
become: True
- name: Ensure kolla group is present
group: name=kolla state=present
become: True
when: create_kolla_user | bool
- name: Create kolla user
user:
name: kolla
state: present
group: kolla
groups: "sudo"
become: True
when: create_kolla_user | bool
- name: Grant kolla user passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^kolla'
line: 'kolla ALL=(ALL) NOPASSWD: ALL'
become: True
when: create_kolla_user | bool
- name: Add public key to kolla user authorized keys
authorized_key:
user: kolla
key: "{{ kolla_ssh_key.public_key }}"
become: True
when: create_kolla_user | bool
- name: Install apt packages
command: apt-get update
become: True
when: ansible_os_family == 'Debian'
- name: Install ubuntu ca certs
package: name={{item}} state=latest
become: True
with_items:
- ca-certificates
- apt-transport-https
when:
- ansible_os_family == 'Debian'
- name: Ensure apt sources list directory exists
file: path=/etc/apt/sources.list.d state=directory recurse=yes
become: True
when: ansible_os_family == 'Debian'
- name: Enable docker repo apt
template:
src: docker_apt_repo.j2
dest: /etc/apt/sources.list.d/docker.list
become: True
when: ansible_os_family == 'Debian'
- name: Install docker apt gpg key
apt_key:
url: "{{ docker_apt_url }}/gpg"
id: "{{ docker_apt_key_id }}"
state: present
become: True
when:
- ansible_os_family == 'Debian'
- ansible_distribution == 'Ubuntu'
- name: Ensure yum repos directory exists
file: path=/etc/yum.repos.d/ state=directory recurse=yes
become: True
when: ansible_os_family == 'RedHat'
- name: Enable docker repo yum
become: True
template:
src: docker_yum_repo.j2
dest: /etc/yum.repos.d/docker.repo
when: ansible_os_family == 'RedHat'
- name: Install docker rpm gpg key
rpm_key:
state: present
key: "{{ docker_yum_url }}/gpg"
become: True
when: ansible_os_family == 'RedHat'
- name: Ensure node_config_directory directory exists
file:
path: "{{ node_config_directory }}"
state: directory
recurse: yes
owner: kolla
group: kolla
mode: 0755
become: True
when: create_kolla_user | bool
- name: Ensure node_config_directory directory exists
file:
path: "{{ node_config_directory }}"
state: directory
recurse: yes
mode: 0666
become: True
when: create_kolla_user | bool == False