Skip to content

Instantly share code, notes, and snippets.

@zsoldosp
Last active August 29, 2015 14:17
Show Gist options
  • Save zsoldosp/777a6fd7d242c2c1dabd to your computer and use it in GitHub Desktop.
Save zsoldosp/777a6fd7d242c2c1dabd to your computer and use it in GitHub Desktop.
Bugreport - ansible template task fails with Errno 26 when run in a ubuntu/trusty64 host via vagrant from a windows 7 x64 host
[default]
hostfile = hosts.ini
#!/bin/bash
#ifconfig | grep inet
if [[ $(which ansible) == "" ]]; then
sudo apt-get install software-properties-common --yes || exit $?
sudo apt-add-repository ppa:ansible/ansible --yes || exit $?
sudo apt-get update || exit $?
sudo apt-get upgrade --yes || exit $?
sudo apt-get install ansible --yes || exit $?
sudo apt-get upgrade ansible --yes || exit $?
fi
cd /vagrant/ || exit $?
DEFAULT_HOSTS_FILE=/etc/ansible/hosts
if [[ -f $DEFAULT_HOSTS_FILE ]]; then
# to fix error ERROR: Unable to find an inventory file, specify one with -i ?
sudo rm $DEFAULT_HOSTS_FILE
fi
# ERROR: The file hosts.ini is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with `chmod -x hosts.ini`.
# on windows every file is executable :(
LOCAL_ANSIBLE_DIR=~/ansible
if [[ -d $LOCAL_ANSIBLE_DIR ]]; then
rm -rf $LOCAL_ANSIBLE_DIR
fi
cp . $LOCAL_ANSIBLE_DIR -R
find $LOCAL_ANSIBLE_DIR -type f | xargs chmod -x
cd $LOCAL_ANSIBLE_DIR
sudo ansible-playbook box.yml -i hosts.ini
---
- hosts: localhost
tasks:
- shell: cp hello.txt.j2 /vagrant/hello.shell.cp.txt # passes
- template: src=hello.txt.j2 dest=/vagrant/hello.template.txt # fails
Hello World from an Ansible template!
localhost ansible_connection=local
# -*- mode: ruby -*-
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", path: "bootstrap.sh"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment