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



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e80a979a-59a6-4525-a1bf-aa9e6d6e4428%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to