Reputation: 8533
I have an ansible playbook which I call from my Vagrantfile:
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provision/playbook.yml"
ansible.sudo = true
ansible.verbose = "vvvv"
ansible.limit = "all"
# ansible.inventory_path = "provision/hosts"
end
This is the playbook:
---
- hosts: all
roles:
- common
My directory structure is:
.
├── provision
│ ├── hosts
│ ├── playbook.yml
│ └── roles
│ └── common
│ ├── install_conda.yml
│ └── reqs.yml
├── ubuntu-xenial-16.04-cloudimg-console.log
└── Vagrantfile
My problem is when I run vagrant up
it does not run the install_conda.yml and reqs.yml
Related output:
ansible/.vagrant/provisioners/ansible/inventory --sudo -vvvv provision/playbook.yml
Using /home/lowks/.ansible.cfg as config file
Loaded callback default of type stdout, v2.0
1 plays in provision/playbook.yml
PLAY ***************************************************************************
TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<127.0.0.1> SSH: EXEC ssh -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/home/lowks/Projects/personal/ansible/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=30 -o ControlPath=/home/lowks/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1465289160.96-19604199657213 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1465289160.96-19604199657213 )" )'
<127.0.0.1> PUT /tmp/lowks/tmpzSsrdn TO /home/ubuntu/.ansible/tmp/ansible-tmp-1465289160.96-19604199657213/setup
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/home/lowks/Projects/personal/ansible/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=30 -o ControlPath=/home/lowks/.ansible/cp/ansible-ssh-%h-%p-%r '[127.0.0.1]'
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<127.0.0.1> SSH: EXEC ssh -C -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/home/lowks/Projects/personal/ansible/.vagrant/machines/default/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=30 -o ControlPath=/home/lowks/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-xokgppdafgvlsnbystytwqbmniidqhhq; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1465289160.96-19604199657213/setup; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1465289160.96-19604199657213/" > /dev/null 2>&1'"'"'"'"'"'"'"'"''"'"''
ok: [default]
PLAY RECAP *********************************************************************
default : ok=1 changed=0 unreachable=0 failed=0
install_conda.yml
---
# necessary steps to deploy the role.
- hosts: all
- name: check if already installed
stat: path=/opt/miniconda2/bin/conda
register: bin_conda
changed_when: bin_conda.stat.exists == False
- name: download miniconda installer
# sudo: no
get_url:
url=https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
dest=/tmp/miniconda.sh
mode=0755
register: miniconda_downloaded
when: bin_conda.stat.exists == False
- name: install miniconda
# sudo: no
shell: "/tmp/miniconda.sh -b -p /opt/miniconda2 creates=/opt/miniconda2 executable=/bin/bash"
register: miniconda_installed
when: miniconda_downloaded | success
notify:
- remove miniconda setup script
- update conda to latest version
What am I missing here ?
Upvotes: 0
Views: 1882
Reputation: 5564
Ansible looks for a main.yml
file in your roles/common/tasks
.
Just add it to your folder
.
├── provision
│ ├── hosts
│ ├── playbook.yml
│ └── roles
│ └── common
│ └── tasks
│ ├── main.yml
│ ├── install_conda.yml
│ └── reqs.yml
├── ubuntu-xenial-16.04-cloudimg-console.log
└── Vagrantfile
and include the other roles:
---
- include: install_conda.yml
- include: reqs.yml
Upvotes: 6