Trouble Setting Directory Ownership On Ubuntu 14.04 Virtualbox

3 views
Skip to first unread message

Kyle Willis

unread,
Jul 31, 2016, 2:14:41 PM7/31/16
to Ansible Project
I am trying to define the ownership for a directory located in a Ubuntu 14.04 Virtual machine, which was created with vagrant and provisioned using Ansible. The approach I'm currently using results in no change to the directory ownership when I `ls -l` the directory. How do I change the directory's user to `foo` and group to `bar`?  

Below I have provided the playbook and Vagrantfile

vagrant.yml:

   
---
   
   
- name: Create a test virtual machine via vagrant
      hosts
: all
      become
: yes
      become_user
: root
      remote_user
: vagrant
      vars
:
       
- setup_git_repo: no
       
- update_apt_cache: yes
   
      tasks
:
   
       
- name: Create the application user
          user
: name="foo" state=present
   
       
- name: Create the application group
         
group: name="bar" system=yes state=present
   
       
- name: Add the application user to the application group
          user
: name="foo" group="bar" state=present
       
       
- name: Set directory previlages
          file
: path="/webapps/ansible_test"    
                owner
="foo"
               
group="bar"
                mode
=0777
                state
=directory




Vagrantfile:


    VAGRANTFILE_API_VERSION
= "2"


   
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config
.vm.box = "trusty64"
      config
.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
      config
.vm.network :forwarded_port, host: 4567, guest: 8000
      config
.vm.provider :virtualbox do |vb|
        vb
.customize ["modifyvm", :id, "--name", "test", "--memory", "512"]
     
end
      config
.vm.synced_folder "../../ansible_test", "/webapps"


      config
.vm.provision "ansible" do |ansible|
        ansible
.playbook = "vagrant.yml"
        ansible
.host_key_checking = false
        ansible
.verbose = "vvv"
     
end
   
end


Result:

 
    vagrant@vagrant-ubuntu-trusty-64:/$ ls -l /webapps
    total
0
    drwxr
-xr-x 1 vagrant vagrant 102 Jul 29 22:00 ansible_test



Reply all
Reply to author
Forward
0 new messages