Closed donovanmuller closed 5 years ago
Seems a duplicate of #107, specifically this https://github.com/radekg/terraform-provisioner-ansible/pull/107#discussion_r257520163
Thank you for reporting this, I will fix that and release a new version. Went unnoticed because it was snug in a more complex pr. Sorry for that!
In the meantime, itβs possible to supply a custom installer program using remote.local_installer_path
.
Will be released soon.
@radekg Any chance we can get a release soon? Thanks
I am really sorry. It will be released this week.
@radekg I'm still getting this error with 2.3.1, specifically with the Ubuntu 18.04 LTS image on GCP.
Hi @donovanmuller, thank you for reporting. I believe not all places were fixed in the code. My fault, totally. I've added the following commit: https://github.com/radekg/terraform-provisioner-ansible/commit/9f97685693e8b1294ed12b1e18c01a309f1d1c1f
The way I've tested this is, I have created the following program locally on disk:
#!/bin/sh
EXPECTED_ANSIBLE_VERSION=${EXPECTED_ANSIBLE_VERSION-"ansible==1.2.2"}
if [ -n "${SIMULATE_ANSIBLE_INSTALLED}" ]; then
touch /bin/ansible-playbook
chmod +x /bin/ansible-playbook
fi
if [ -n "${TAF_DOCKER_CENTOS_LATEST_RUN}" ]; then
yum update -y && yum install -y which
fi
set -eu
if [ -z "$(which ansible-playbook)" ]; then
# only check the cloud boot finished if the directory exists
if [ -d /var/lib/cloud/instance ]; then
while [ -f /var/lib/cloud/instance/boot-finished ]; do
sleep 1
done
fi
# install dependencies
if [ -f /etc/redhat-release ]; then
yum update -y \
&& yum groupinstall -y "Development Tools" \
&& yum install -y python-devel
else
echo "apt-get update && apt-get install -y build-essential python-dev"
fi
# install pip, if necessary
if [ -z "$(which pip)" ]; then
echo "curl https://bootstrap.pypa.io/get-pip.py | python"
fi
# install ansible
# pip install {{ .AnsibleVersion}}
echo "should install ${EXPECTED_ANSIBLE_VERSION}"
else
expected_version="${EXPECTED_ANSIBLE_VERSION}"
installed_version="1.2.2"
installed_version="ansible==$installed_version"
case "$expected_version" in
*==*)
if [ "$expected_version" != "$installed_version" ]; then
echo "pip install $expected_version"
fi
;;
esac
fi
This very closely matches the installer program from the commit referenced above. I then executed these docker commands:
build-essential
and python-dev
followed by should install ansible==1.2.2
[rad] script-test $ docker run -ti --rm -v $(pwd):/usr/scripts ubuntu:18.04 /bin/sh -c '/usr/scripts/program.sh'
apt-get update && apt-get install -y build-essential python-dev
curl https://bootstrap.pypa.io/get-pip.py | python
should install ansible==1.2.2
[rad] script-test $ docker run -ti --rm -v $(pwd):/usr/scripts -e SIMULATE_ANSIBLE_INSTALLED=1 ubuntu:18.04 /bin/sh -c '/usr/scripts/program.sh'
[rad] script-test $
pip install ansible==1.2.3
:[rad] script-test $ docker run -ti --rm -v $(pwd):/usr/scripts -e SIMULATE_ANSIBLE_INSTALLED=1 -e EXPECTED_ANSIBLE_VERSION=ansible==1.2.3 ubuntu:18.04 /bin/sh -c '/usr/scripts/program.sh'
pip install ansible==1.2.3
It seems to be correct now.
Thanks for the speedy resolution π
I will cut a release within a few hours.
I think I'm hitting the same bug. Waiting for the release :)
Version 2.3.2 is out. Please let me know if this finally solves the problem.
@radekg Will do as soon as I can. Thanks for the release π
Steps to reproduce
Using GCP Compute Instance and the Ubuntu 18.04 LTS image I get the following error when trying to install Ansible on the remote bastion:
If I run the script manually (SSH into the bastion) with (see https://unix.stackexchange.com/a/155881/131307):
Ansible is installed correctly.
Expected behavior
The
tf-ansible-installer
script runs successfully and installs Ansible on the remote bastion host.Actual behavior
Configuration
Terraform version:
terraform-provisioner-ansible version/SHA:
Terraform file / provisioner configuration:
Terraform run log: