Ansible 2.1.0 using become/become_user fails to set permissions on temp file

DeamonMV picture DeamonMV · Apr 15, 2016 · Viewed 15.4k times · Source

I have an ansible 2.1.0 on my server, where I do deployment via vagrant and on PC too. The role "deploy" have :

- name: upload code
  become: true
  become_user: www-data
  git: [email protected]:****.git
     dest=/var/www/main
     key_file=/var/www/.ssh/id_rsa
     accept_hostkey=true
     update=yes
     force=yes
 register: fresh_code
 notify: restart php-fpm
 tags: fresh_code

In this case with ansible 2.1.0 I get an error:

fatal: [default]: FAILED! => {"failed": true, "msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user. For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}

It it ansible 2.0.1.0 which I use on my PC, is all normally - folder /var/www/ have folder main with owner and group www-data

If I use only became_user: www-data and if I use become_method: sudo with became_user: www-data - i got same error

What need to do to resolve this?

Answer

Justin Ludwig picture Justin Ludwig · May 8, 2016

On debian/ubuntu you can resolve this by first installing the acl package on the remote host, like with this ansible task:

- name: install setfacl support
  become: yes
  apt: pkg=acl

Same thing with redhat/centos -- install the acl package on the remote host:

- name: install setfacl support
  become: yes
  yum: name=acl