kolla-ansible/ansible/roles/manila/tasks/fix_cephfs_owner.yml
Mark Goddard b123bf6621 Use become for all docker tasks
Many tasks that use Docker have become specified already, but
not all. This change ensures all tasks that use the following
modules have become:

* kolla_docker
* kolla_ceph_keyring
* kolla_toolbox
* kolla_container_facts

It also adds become for 'command' tasks that use docker CLI.

Change-Id: I4a5ebcedaccb9261dbc958ec67e8077d7980e496
2019-06-06 19:04:58 +01:00

84 lines
2.4 KiB
YAML

---
- name: Check /tmp/cephfs path
become: true
command: "docker exec -u 0 manila_share ls /tmp/cephfs/"
register: check_cephfs
changed_when: False
failed_when: check_cephfs.rc != 0 and check_cephfs.stderr.find('No such file or directory') == -1
run_once: True
- name: Create /tmp/cephfs path
become: true
command: "docker exec -u 0 manila_share mkdir -p /tmp/cephfs"
run_once: True
when: check_cephfs.rc != 0
- name: Get monitor dump
become: true
command: docker exec manila_share ceph mon dump -c /etc/ceph/ceph.conf --name client.manila -f json
register: ceph_monitor_dump
changed_when: False
run_once: True
- name: Get cephfs addr
vars:
query: mons[*].public_addr
# take only ip and port from public_addr, e.g from public_addr: 10.66.1.5:6789/0
# use 10.66.1.5:6789
regex: "[^/]*"
set_fact:
cephfs_addr: "{{ ceph_monitor_dump.stdout | from_json | json_query(query) | map('regex_search', regex) | join(',') }}:/"
run_once: true
- name: Get cephfs secret
become: true
command: docker exec manila_share ceph-authtool -p /etc/ceph/ceph.client.manila.keyring -n client.manila
register: manila_keyring
changed_when: False
run_once: True
- name: Umount cephfs
become: true
command: "docker exec -u 0 manila_share umount /tmp/cephfs/"
register: umount_cephfs
changed_when: False
failed_when: False
run_once: True
- name: Mount cephfs
become: true
command: "docker exec -u 0 manila_share mount -t ceph {{cephfs_addr}} /tmp/cephfs -o name=manila,secret={{ manila_keyring.stdout }}"
register: mount_cephfs
changed_when: False
run_once: True
- name: Check volumes path
become: true
command: "docker exec -u 0 manila_share ls /tmp/cephfs/volumes"
register: check_volume
changed_when: False
failed_when: False
run_once: True
- name: Create /tmp/cephfs/volumes path
become: true
command: "docker exec -u 0 manila_share mkdir /tmp/cephfs/volumes"
register: create_volume
run_once: True
when: check_volume.rc != 0
- name: Change the owner and group of /tmp/cephfs/volumes
become: true
command: "docker exec -u 0 manila_share chown manila:manila /tmp/cephfs/volumes"
register: chown_volume
run_once: True
when: check_volume.rc != 0 and create_volume.rc == 0
- name: Umount cephfs
become: true
command: "docker exec -u 0 manila_share umount /tmp/cephfs"
changed_when: False
register: umount_cephfs
run_once: True
when: mount_cephfs.rc == 0