kolla-ansible/ansible/roles/manila/tasks/fix_cephfs_owner.yml
Michal Nasiadka 2128075c6e Ansible lint related fixes
Change-Id: I146ea3d84efb83ec5d7405644ad372e57ecafc1e
2020-05-12 17:39:07 +00:00

86 lines
2.8 KiB
YAML

---
- name: Check /tmp/cephfs path
become: true
command: "docker exec -u 0 {{ manila_services['manila-share']['container_name'] }} 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_services['manila-share']['container_name'] }} mkdir -p /tmp/cephfs"
run_once: True
when: check_cephfs.rc != 0
- name: Get monitor dump
become: true
command: docker exec "{{ manila_services['manila-share']['container_name'] }}" 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_services['manila-share']['container_name'] }}" 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_services['manila-share']['container_name'] }} 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_services['manila-share']['container_name'] }}
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_services['manila-share']['container_name'] }} 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_services['manila-share']['container_name'] }} 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_services['manila-share']['container_name'] }} 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_services['manila-share']['container_name'] }} umount /tmp/cephfs"
changed_when: False
register: umount_cephfs
run_once: True
when: mount_cephfs.rc == 0