首页 > 解决方案 > 使用 Ansible 创建目录会导致 /usr/lib/python3.7 中的文件所有权更改

问题描述

使用 Ubuntu 19.04 和 Python 3.7

当我使用 Ansible 创建目录时,文件所有权在 /usr/lib/python3.7 中更改

显然这不应该发生,它会破坏整个 Ubuntu 的 Python,直到权限得到纠正。

该问题仅在使用 recurse=yes 时发生

这是一个显示问题的视频: https ://youtu.be/d3hj255pW9w

这是代码/Ansible 剧本:

ubuntu@ubuntu-GB-BXi3-5010:~/ansible$ cat ~/ansible/renderworker/ffmpegconverter/ansible/test.yml
---
- hosts: renderworkerhosts
  become: yes

  tasks:

    # for some reason, recurse=yes results in owner & permissions changing in /usr/lib/python3.7
    # which breaks Python on Ubuntu

    - name: Create directory
      file:
        path=/opt/ffmpegconverter
        state=directory
        owner=root
        group=ffmpeguser
        mode=u=rwx,g=rwx,o=
        recurse=yes

ubuntu@ubuntu-GB-BXi3-5010:~/ansible$

标签: ansible

解决方案


您应该使用冒号而不是等号作为键和值之间的分隔符:

path: /etc/foo.conf

推荐阅读