diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 3aeafe703e..69a42f919b 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -359,6 +359,7 @@ openstack_auth: password: "{{ keystone_admin_password }}" project_name: "admin" domain_name: "default" + user_domain_name: "default" # Endpoint type used to connect with OpenStack services with ansible modules. # Valid options are [ public, internal, admin ] diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 2cfb598a81..ffa40675d8 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -345,6 +345,9 @@ cloudkitty [freezer-api:children] freezer +[freezer-scheduler:children] +freezer + # iSCSI [iscsid:children] compute diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 71c7760374..61918913e6 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -364,6 +364,9 @@ cloudkitty [freezer-api:children] freezer +[freezer-scheduler:children] +freezer + # iSCSI [iscsid:children] compute diff --git a/ansible/roles/freezer/defaults/main.yml b/ansible/roles/freezer/defaults/main.yml index 99d4bba8f2..51e32c4a5d 100644 --- a/ansible/roles/freezer/defaults/main.yml +++ b/ansible/roles/freezer/defaults/main.yml @@ -12,6 +12,16 @@ freezer_services: - "/etc/localtime:/etc/localtime:ro" - "freezer:/var/lib/freezer/" - "kolla_logs:/var/log/kolla/" + freezer-scheduler: + container_name: freezer_scheduler + group: freezer-scheduler + enabled: true + image: "{{ freezer_scheduler_image_full }}" + volumes: + - "{{ node_config_directory }}/freezer-scheduler/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "freezer:/var/lib/freezer/" + - "kolla_logs:/var/log/kolla/" #################### @@ -20,6 +30,9 @@ freezer_services: freezer_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-freezer-api" freezer_api_tag: "{{ openstack_release }}" freezer_api_image_full: "{{ freezer_api_image }}:{{ freezer_api_tag }}" +freezer_scheduler_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-freezer-scheduler" +freezer_scheduler_tag: "{{ openstack_release }}" +freezer_scheduler_image_full: "{{ freezer_scheduler_image }}:{{ freezer_scheduler_tag }}" #################### diff --git a/ansible/roles/freezer/handlers/main.yml b/ansible/roles/freezer/handlers/main.yml index e5c7ac507f..283bd47a04 100644 --- a/ansible/roles/freezer/handlers/main.yml +++ b/ansible/roles/freezer/handlers/main.yml @@ -22,3 +22,26 @@ or freezer_conf.changed | bool or policy_overwriting.changed | bool or freezer_api_container.changed | bool + +- name: Restart freezer-scheduler container + vars: + service_name: "freezer-scheduler" + service: "{{ freezer_services[service_name] }}" + config_json: "{{ freezer_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}" + freezer_conf: "{{ freezer_confs.results|selectattr('item.key', 'equalto', service_name)|first }}" + policy_overwriting: "{{ freezer_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}" + freezer_scheduler_container: "{{ check_freezer_containers.results|selectattr('item.key', 'equalto', service_name)|first }}" + kolla_docker: + action: "recreate_or_restart_container" + common_options: "{{ docker_common_options }}" + name: "{{ service.container_name }}" + image: "{{ service.image }}" + volumes: "{{ service.volumes }}" + when: + - action != "config" + - inventory_hostname in groups[service.group] + - service.enabled | bool + - config_json.changed | bool + or freezer_conf.changed | bool + or policy_overwriting.changed | bool + or freezer_scheduler_container.changed | bool diff --git a/ansible/roles/freezer/tasks/config.yml b/ansible/roles/freezer/tasks/config.yml index 8f6015b223..4d191a829d 100644 --- a/ansible/roles/freezer/tasks/config.yml +++ b/ansible/roles/freezer/tasks/config.yml @@ -41,33 +41,34 @@ - item.value.enabled | bool with_dict: "{{ freezer_services }}" notify: - - Restart freezer-api container + - "Restart {{ item.key }} container" - name: Copying over wsgi-freezer-api.conf + vars: + service: "{{ freezer_services['freezer-api'] }}" template: src: "wsgi-freezer-api.conf.j2" - dest: "{{ node_config_directory }}/{{ item.key }}/wsgi-freezer-api.conf" + dest: "{{ node_config_directory }}/freezer-api/wsgi-freezer-api.conf" mode: "0660" become: true register: wsgi_freezer_api when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ freezer_services }}" + - inventory_hostname in groups[service.group] + - service.enabled | bool notify: - Restart freezer-api container -- name: Copying over freezer-api.conf +- name: Copying over freezer confs vars: service_name: "{{ item.key }}" merge_configs: sources: - - "{{ role_path }}/templates/freezer-api.conf.j2" + - "{{ role_path }}/templates/freezer.conf.j2" - "{{ node_custom_config }}/global.conf" - "{{ node_custom_config }}/freezer.conf" - "{{ node_custom_config }}/freezer/{{ item.key }}.conf" - "{{ node_custom_config }}/freezer/{{ inventory_hostname }}/{{ item.key }}.conf" - dest: "{{ node_config_directory }}/{{ item.key }}/freezer-api.conf" + dest: "{{ node_config_directory }}/{{ item.key }}/freezer.conf" mode: "0660" become: true register: freezer_confs @@ -76,7 +77,7 @@ - item.value.enabled | bool with_dict: "{{ freezer_services }}" notify: - - Restart freezer-api container + - "Restart {{ item.key }} container" - name: Copying over existing policy file template: @@ -91,7 +92,7 @@ - item.value.enabled | bool with_dict: "{{ freezer_services }}" notify: - - Restart freezer-api container + - "Restart {{ item.key }} container" - name: Check freezer containers kolla_docker: @@ -107,4 +108,4 @@ - item.value.enabled | bool with_dict: "{{ freezer_services }}" notify: - - Restart freezer-api container + - "Restart {{ item.key }} container" diff --git a/ansible/roles/freezer/tasks/pull.yml b/ansible/roles/freezer/tasks/pull.yml index bc912d465e..fd00948c6a 100644 --- a/ansible/roles/freezer/tasks/pull.yml +++ b/ansible/roles/freezer/tasks/pull.yml @@ -1,5 +1,5 @@ --- -- name: Pulling freezer image +- name: Pulling freezer images kolla_docker: action: "pull_image" common_options: "{{ docker_common_options }}" diff --git a/ansible/roles/freezer/templates/freezer-api.json.j2 b/ansible/roles/freezer/templates/freezer-api.json.j2 index afc8fa913d..1c25a9d1bc 100644 --- a/ansible/roles/freezer/templates/freezer-api.json.j2 +++ b/ansible/roles/freezer/templates/freezer-api.json.j2 @@ -4,7 +4,7 @@ "command": "{{ apache_cmd }} -DFOREGROUND", "config_files": [ { - "source": "{{ container_config_directory }}/freezer-api.conf", + "source": "{{ container_config_directory }}/freezer.conf", "dest": "/etc/freezer/freezer.conf", "owner": "freezer", "perm": "0600" diff --git a/ansible/roles/freezer/templates/freezer-scheduler.json.j2 b/ansible/roles/freezer/templates/freezer-scheduler.json.j2 new file mode 100644 index 0000000000..f892d725cc --- /dev/null +++ b/ansible/roles/freezer/templates/freezer-scheduler.json.j2 @@ -0,0 +1,24 @@ +{ + "command": "freezer-scheduler --config-file /etc/freezer/freezer.conf start", + "config_files": [ + { + "source": "{{ container_config_directory }}/freezer.conf", + "dest": "/etc/freezer/freezer.conf", + "owner": "freezer", + "perm": "0600" + }{% if freezer_policy_file is defined %}, + { + "source": "{{ container_config_directory }}/{{ freezer_policy_file }}", + "dest": "/etc/freezer/{{ freezer_policy_file }}", + "owner": "freezer", + "perm": "0600" + }{% endif %} + ], + "permissions": [ + { + "path": "/var/log/kolla/freezer", + "owner": "freezer:freezer", + "recurse": true + } + ] +} diff --git a/ansible/roles/freezer/templates/freezer-api.conf.j2 b/ansible/roles/freezer/templates/freezer.conf.j2 similarity index 72% rename from ansible/roles/freezer/templates/freezer-api.conf.j2 rename to ansible/roles/freezer/templates/freezer.conf.j2 index eb4c59562e..510fe7495d 100644 --- a/ansible/roles/freezer/templates/freezer-api.conf.j2 +++ b/ansible/roles/freezer/templates/freezer.conf.j2 @@ -8,6 +8,19 @@ bind_host = {{ api_interface_address }} bind_port = {{ freezer_api_port }} {% endif %} +{% if service_name == 'freezer-scheduler' %} +client_id = {{ inventory_hostname }} +jobs_dir = /etc/freezer/scheduler/conf.d + +os_username = {{ openstack_auth.username }} +os_password = {{ openstack_auth.password }} +os_auth_url = {{ openstack_auth.auth_url }}/v3 +os_project_name = {{ openstack_auth.project_name }} +os_project_domain_name = {{ openstack_auth.domain_name }} +os_user_domain_name = {{ openstack_auth.user_domain_name }} +{% endif %} + +{% if service_name == 'freezer-api' %} [keystone_authtoken] auth_uri = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_public_port }} auth_url = {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }} @@ -38,3 +51,4 @@ driver = freezer_api.storage.elasticv2.ElasticSearchEngineV2 hosts = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ elasticsearch_port }} number_of_replicas = 0 index = freezer +{% endif %} diff --git a/releasenotes/notes/add-freezer-sceduler-b646fba6666889a1.yaml b/releasenotes/notes/add-freezer-sceduler-b646fba6666889a1.yaml new file mode 100644 index 0000000000..d76a6f18ff --- /dev/null +++ b/releasenotes/notes/add-freezer-sceduler-b646fba6666889a1.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add a kolla-ansible role for freezer-scheduler