/
glance_install.yml
149 lines (137 loc) · 4.57 KB
/
glance_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
---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Record the installation method
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: "glance"
option: "install_method"
value: "{{ glance_install_method }}"
- name: Refresh local facts to ensure the glance section is present
setup:
filter: ansible_local
gather_subset: "!all"
- name: create the system group
group:
name: "{{ glance_system_group_name }}"
gid: "{{ glance_system_group_gid | default(omit) }}"
state: "present"
system: "yes"
- name: Create the glance system user
user:
name: "{{ glance_system_user_name }}"
uid: "{{ glance_system_user_uid | default(omit) }}"
group: "{{ glance_system_group_name }}"
comment: "{{ glance_system_comment }}"
shell: "{{ glance_system_shell }}"
system: "yes"
createhome: "yes"
home: "{{ glance_system_user_home }}"
- name: Create glance NFS mount point(s)
file:
path: "{{ item.local_path }}"
state: directory
mode: "0755"
with_items: "{{ glance_nfs_client }}"
- name: Create glance directories
file:
path: "{{ item.path | realpath }}"
state: directory
owner: "{{ item.owner | default(glance_system_user_name) }}"
group: "{{ item.group | default(glance_system_group_name) }}"
mode: "{{ item.mode | default(omit) }}"
when:
- "item.path not in glance_mount_points"
with_items:
- path: "/openstack"
mode: "0755"
owner: "root"
group: "root"
- path: "/etc/glance"
mode: "0750"
- path: "/var/cache/glance"
- path: "{{ glance_system_user_home }}"
- path: "{{ glance_system_user_home }}/cache/api"
mode: "0700"
- path: "{{ glance_system_user_home }}/cache/registry"
- path: "{{ glance_system_user_home }}/scrubber"
- path: "{{ glance_system_user_home }}/images"
mode: "0755"
- path: "/var/log/glance"
mode: "0755"
- name: Install distro packages
package:
name: "{{ glance_package_list }}"
state: "{{ glance_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages is success
retries: 5
delay: 2
- name: Install glance packages from PIP
include_tasks: glance_install_source.yml
when: glance_install_method == 'source'
- name: Record the need for a service restart
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: "glance"
option: "need_service_restart"
value: true
when: (install_packages | changed) or
('need_service_restart' not in ansible_local['openstack_ansible']['glance'])
- name: Run the systemd service role
include_role:
name: systemd_service
private: true
vars:
systemd_user_name: "{{ glance_system_user_name }}"
systemd_group_name: "{{ glance_system_group_name }}"
systemd_tempd_prefix: openstack
systemd_slice_name: glance
systemd_lock_path: /var/lock/glance
systemd_CPUAccounting: true
systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true
systemd_TasksAccounting: true
systemd_services:
- service_name: "{{ service_var.service_name }}"
enabled: yes
state: started
execstarts: "{{ service_var.execstarts }}"
execreloads: "{{ service_var.execreloads | default([]) }}"
config_overrides: "{{ service_var.init_config_overrides }}"
with_items: "{{ filtered_glance_services }}"
loop_control:
loop_var: service_var
tags:
- glance-config
- systemd-service
- name: Ensure uWSGI directory exists
file:
path: "/etc/uwsgi/"
state: directory
mode: "0711"
- name: Apply uWSGI configuration
config_template:
src: "glance-uwsgi.ini.j2"
dest: "/etc/uwsgi/{{ item.service_name }}.ini"
mode: "0744"
config_overrides: "{{ item.wsgi_overrides }}"
config_type: ini
with_items: "{{ filtered_glance_services }}"
when: item.wsgi_app | default(False)
notify:
- Manage LB
- Restart glance services