tripleo-ansible/tripleo_ansible/playbooks/docker-vfs-setup.yml
Kevin Carter 4c2d54e95c Replace all references to the old role name
This change replaces all of the roles references in our various files with the
new role name. This is being done because Ansible no longer allows hyphens in
role names.

Change-Id: Ie899714aca49781ccd240bb259901d76f177d2ae
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2020-01-22 12:06:06 +00:00

111 lines
3.3 KiB
YAML

---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Docker vfs setup
hosts: all
gather_facts: true
handlers:
- name: Stop docker daemon
become: true
systemd:
name: docker
state: stopped
listen: Restart docker
- name: Start docker daemon
become: true
systemd:
name: docker
state: started
listen: Restart docker
- name: Cleanup temp json file
become: true
file:
path: "{{ tripleo_docker_temp_file }}"
state: absent
pre_tasks:
- name: Set temp file fact
set_fact:
tripleo_docker_temp_file: "{{ ansible_user_dir }}/.ansible/tmp/docker-daemon-{{ inventory_hostname }}.json"
when:
- tripleo_docker_temp_file is undefined
tasks:
- name: Storage driver block
become: true
when:
- (tripleo_docker_enable_vfs | default(false)) | bool
block:
- name: Create ansible temp directory
file:
path: "{{ tripleo_docker_temp_file | dirname }}"
state: directory
- name: Check for docker json file
stat:
path: /etc/docker/daemon.json
register: daemon_json
- name: Store config file
fetch:
src: /etc/docker/daemon.json
dest: "{{ tripleo_docker_temp_file }}"
flat: true
register: stored_file
when:
- daemon_json.stat.exists | bool
notify:
- Cleanup temp json file
- name: Insert storage-driver into docker daemon config (existing)
include_role:
name: tripleo_config
vars:
tripleo_config_src: "{{ tripleo_docker_temp_file }}"
tripleo_config_type: json
tripleo_config_dest: /etc/docker/daemon.json
tripleo_config_overrides:
storage-driver: vfs
when:
- daemon_json.stat.exists | bool
- name: Insert storage-driver into docker daemon config (new)
include_role:
name: tripleo_config
vars:
tripleo_config_type: json
tripleo_config_dest: /etc/docker/daemon.json
tripleo_config_overrides:
storage-driver: vfs
when:
- not (daemon_json.stat.exists | bool)
post_tasks:
- name: Get checksum from running docker config
stat:
path: /etc/docker/daemon.json
register: running_file
- name: Notify config changes
debug:
msg: "Configuration changes detected notifying handlers"
changed_when: true
when:
- (not (stored_file.changed | bool)) or
(stored_file.checksum != running_file.stat.checksum)
notify:
- Restart docker