使用Ansible 2.1.4.0
是否可以sticky bit
在1个任务中设置和文件夹权限?
例;
# Shell is used over find module cause symlink breaks and performance - name: Find directories in /tmp which are not valid shell: find /tmp/test -type d \( ! -user root -o ! -group root -o ! -perm 775 \) register: find1 - name: Set 775 for found directories file: path: "{{ item }}" owner: root group: vagrant mode: 0775 state: directory with_items: "{{ findPermission1.stdout_lines | default([]) }}" - name: Find directories in /tmp which have no sticky bit shell: find /tmp/test -type d \! -perm /1000 changed_when: false register: find2 - name: Set permissions for found directories file: path: "{{ item }}" owner: root group: vagrant mode: g+s state: directory recurse: no #cause it already found recurse with_items: "{{ find.stdout_lines | default([]) }}"
现在,我必须有2个不同的任务来设置权限.但是他们互相覆盖.
目标:在一项任务中将权限设置为775和g + s.
找到了. http://docs.ansible.com/ansible/file_module.html
- name: Set sticky bit + 775 for directory file: path: /tmp/test owner: root group: vagrant mode: u=rwx,g=rwx,o=rx,g+s state: directory