aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/glance/tasks/config.yml
blob: c7e91de5b86e62021fa82cf027d763475e9c2417 (plain)
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
---
- name: Ensuring config directories exist
  ansible.builtin.file:
    path: "{{ node_config_directory }}/{{ item.key }}"
    state: "directory"
    owner: "{{ config_owner_user }}"
    group: "{{ config_owner_group }}"
    mode: "0770"
  become: true
  with_dict: "{{ glance_services | select_services_enabled_and_mapped_to_host }}"

- name: Include tasks from external_ceph.yml
  ansible.builtin.include_tasks: external_ceph.yml
  when:
    - glance_backend_ceph | bool

- name: Check if policies shall be overwritten
  ansible.builtin.stat:
    path: "{{ item }}"
  delegate_to: localhost
  run_once: true
  register: glance_policy
  with_first_found:
    - files: "{{ supported_policy_format_list }}"
      paths:
        - "{{ node_custom_config }}/glance/"
      skip: true

- name: Set glance policy file
  ansible.builtin.set_fact:
    glance_policy_file: "{{ glance_policy.results.0.stat.path | basename }}"
    glance_policy_file_path: "{{ glance_policy.results.0.stat.path }}"
  when:
    - glance_policy.results | length > 0

- name: Copying over TLS certificates
  ansible.builtin.include_tasks: copy-certs.yml
  when:
    - glance_copy_certs | bool

- name: Copying over config.json files for services
  ansible.builtin.template:
    src: "{{ item.key }}.json.j2"
    dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
    mode: "0660"
  become: true
  with_dict: "{{ glance_services | select_services_enabled_and_mapped_to_host }}"

- name: "Configure uWSGI for Glance"
  ansible.builtin.include_role:
    name: service-uwsgi-config
  vars:
    _glance_uwsgi_cacert_env:
      REQUESTS_CA_BUNDLE: "{{ openstack_cacert }}"
      SSL_CERT_FILE: "{{ openstack_cacert }}"
    project_services: "{{ glance_services }}"
    service: "{{ glance_services['glance-api'] }}"
    service_name: "glance-api"
    service_uwsgi_config_chunked_input_limit: "{{ '64M' | human_to_bytes }}"
    service_uwsgi_config_env: "{{ _glance_uwsgi_cacert_env if kolla_enable_tls_internal else {} }}"
    service_uwsgi_config_http_port: "{{ glance_api_listen_port }}"
    service_uwsgi_config_log_file_chmod: "644"
    service_uwsgi_config_module: "{{ service.wsgi }}"
    service_uwsgi_config_tls_backend: "{{ glance_enable_tls_backend | bool }}"
    service_uwsgi_config_tls_cert: "/etc/glance/certs/glance-cert.pem"
    service_uwsgi_config_tls_key: "/etc/glance/certs/glance-key.pem"
    service_uwsgi_config_workers: "{{ glance_api_workers }}"
    service_uwsgi_config_uid: "glance"
  when:
    - service | service_enabled_and_mapped_to_host

- name: Copying over glance-api.conf
  vars:
    service: "{{ glance_services['glance-api'] }}"
  merge_configs:
    sources:
      - "{{ role_path }}/templates/glance-api.conf.j2"
      - "{{ node_custom_config }}/global.conf"
      - "{{ node_custom_config }}/glance.conf"
      - "{{ node_custom_config }}/glance/glance-api.conf"
      - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/glance-api.conf"
    dest: "{{ node_config_directory }}/glance-api/glance-api.conf"
    mode: "0660"
  become: true
  when: service | service_enabled_and_mapped_to_host

- name: Copying over glance-cache.conf for glance_api
  vars:
    service: "{{ glance_services['glance-api'] }}"
  merge_configs:
    sources:
      - "{{ role_path }}/templates/glance-cache.conf.j2"
      - "{{ node_custom_config }}/glance-cache.conf"
      - "{{ node_custom_config }}/glance/glance-cache.conf"
      - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/glance-cache.conf"
    dest: "{{ node_config_directory }}/glance-api/glance-cache.conf"
    mode: "0660"
  become: true
  when:
    - service | service_enabled_and_mapped_to_host
    - enable_glance_image_cache | bool

- name: Copying over glance-image-import.conf
  vars:
    service: "{{ glance_services['glance-api'] }}"
  ansible.builtin.copy:
    src: "{{ node_custom_config }}/glance/glance-image-import.conf"
    dest: "{{ node_config_directory }}/glance-api/glance-image-import.conf"
    mode: "0660"
  become: true
  when:
    - service | service_enabled_and_mapped_to_host
    - glance_enable_interoperable_image_import | bool

- name: Copying over property-protections-rules.conf
  vars:
    service: "{{ glance_services['glance-api'] }}"
  ansible.builtin.copy:
    src: "{{ node_custom_config }}/glance/property-protections-rules.conf"
    dest: "{{ node_config_directory }}/glance-api/property-protections-rules.conf"
    mode: "0660"
  become: true
  when:
    - service | service_enabled_and_mapped_to_host
    - glance_enable_property_protection | bool

- name: Copying over existing policy file
  vars:
    service: "{{ glance_services['glance-api'] }}"
  ansible.builtin.template:
    src: "{{ glance_policy_file_path }}"
    dest: "{{ node_config_directory }}/glance-api/{{ glance_policy_file }}"
    mode: "0660"
  become: true
  when:
    - glance_policy_file is defined
    - service | service_enabled_and_mapped_to_host