This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
/
install.yml
212 lines (187 loc) · 6.92 KB
/
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
- block:
- name: Update apt package index
apt:
update_cache: yes
when: ansible_distribution == 'Debian'
# This is a lie, but necessary for Idempotence test
changed_when: False
# Break the loop once the first package name/URL in the list is found to be installed.
# The yum module (which wraps the yum command) uses rc=126 for package not
# found, or 0 for changed / already installed.
- name: Install EPEL Release
yum:
name: "{{ item }}"
state: present
# dnf/yum4 registered results not implemented yet
use_backend: yum
register: epel
when:
- (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat')
# Works for both strings and lists to make sure not empty
- epel_release_packages is defined
- epel_release_packages is not none
- epel_release_packages | length > 0
- ( ansible_loop.first ) or (epel.rc == 126)
failed_when:
- epel.rc not in [0,126]
- ( ansible_loop.last ) and (epel.rc == 126)
# Cast a single string as a list.
loop: "{{ lookup('vars', 'epel_release_packages', wantlist=True) }}"
loop_control:
extended: True
- name: Install prerequisites
package:
name: '{{ pulp_preq_packages }}'
state: present
# Needed by psycopg2-binary from PyPI
- name: Install prerequisites (Fedora 30+ only)
package:
name: libxcrypt-compat
state: present
when:
- ansible_distribution == "Fedora"
- ansible_distribution_version|int >= 30
- name: Disable SELinux (Pulp 3 is currently incompatible with SELinux)
selinux:
policy: targeted
state: permissive
when: ansible_os_family == 'RedHat'
# Become root so as to search paths like /usr/sbin.
- name: Find the nologin executable
command: which nologin
changed_when: False
check_mode: False
register: result
- name: Make sure {{ pulp_group }} group exists
group:
name: '{{ pulp_group }}'
gid: '{{ pulp_group_id }}'
state: present
system: true
- name: Create user {{ pulp_user }}
user:
name: '{{ pulp_user }}'
uid: '{{ pulp_user_id }}'
shell: '{{ result.stdout.strip() }}'
home: '{{ pulp_user_home }}'
system: true
when: developer_user is not defined
- name: Add user {{ pulp_user }} to {{ pulp_group }} group
user:
name: '{{ pulp_user }}'
groups:
- '{{ pulp_group }}'
append: true
- name: Add user {{ developer_user }} to {{ pulp_group }} group
user:
name: '{{ developer_user }}'
groups:
- '{{ pulp_group }}'
append: true
when: developer_user is defined
- name: Reset ssh conn to allow user changes to affect when ssh user and pulp user are the same
meta: reset_connection
- name: Create cache dir for Pulp
file:
path: '{{ pulp_cache_dir }}'
state: directory
owner: '{{ pulp_user }}'
group: '{{ pulp_group }}'
mode: 0775
- name: Create pulp install dir
file:
path: '{{ pulp_install_dir }}'
state: directory
owner: '{{ pulp_user }}'
group: '{{ pulp_group }}'
- name: Install packages needed for source install
package:
name:
- git
state: present
register: result
until: result is succeeded
# We are purposely running this before the venv is created, since
# if we are using system-wide packages, it could cause duplicate
# python packages to be installed.
# Note: We would do a static import like in pulp-database, but
# looping does not work with it, so we do a dynamic include.
- name: Include plugins prereq roles
include_role:
name: "{{ item.value.prereq_role }}"
with_dict: "{{ pulp_install_plugins }}"
when: item.value.prereq_role is defined
become: true
- block:
# Hack for use system-wide packages when enabled by user - Must be first usage of virtualenv
- name: Allow use system-wide packages
pip:
name: pip
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
virtualenv_site_packages: yes
when: pulp_use_system_wide_pkgs |bool
- name: Install the psycopg python package
pip:
name: psycopg2-binary
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
- name: Install the prereq_pip_packages
pip:
name: '{{ prereq_pip_packages }}'
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
when: prereq_pip_packages | length > 0
- name: Install pulpcore package from source
pip:
name: '{{ pulp_source_dir }}'
editable: '{{ pulp_pip_editable }}'
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
when: pulp_source_dir is defined
# This is a hack. Editable pip installs are always changed, which fails molecule's
# idempotence test.
changed_when: result.changed and not pulp_pip_editable
notify: Collect static content
- name: Install pulpcore-plugin package from source
pip:
name: '{{ pulp_plugin_source_dir }}'
editable: '{{ pulp_pip_editable }}'
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
when: pulp_plugin_source_dir is defined
# This is a hack. Editable pip installs are always changed, which fails molecule's
# idempotence test.
changed_when: result.changed and not pulp_pip_editable
notify: Collect static content
- name: Install Pulp plugins via PyPI
pip:
name: '{{ item.key }}'
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
with_dict: '{{ pulp_install_plugins }}'
when: pulp_install_plugins[item.key].source_dir is undefined
notify: Collect static content
- name: Install Pulp plugins from source
pip:
name: '{{ item.value.source_dir }}'
editable: '{{ pulp_pip_editable }}'
state: present
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
with_dict: '{{ pulp_install_plugins }}'
when: pulp_install_plugins[item.key].source_dir is defined
# This is a hack. Editable pip installs are always changed, which fails molecule's
# idempotence test.
changed_when: result.changed and not pulp_pip_editable
notify: Collect static content
become: true
become_user: '{{ pulp_user }}'
...