---
- hosts: testhost
become: yes
tasks:
- name: change user profile
copy: src=/tmp/profile dest=/home/test/.bash_profile force=no owner=test group=test
- name: update bashrc
copy: src=/tmp/bashrc dest=/home/test/.bashrc owner=test group=test force=no
- name: add umask to the file
lineinfile: dest=/home/test/.bashrc create=no line="umask 022" create=no
答案1
看起来是copy
创建了该文件。该行不会修改已存在的文件(因为force=no
),但如果不存在,则会修改。
然后,lineinfile
将确保该文件包含umask 022
。