I am trying to customize the VM under the hood of an Azure DevOps pipeline based on Ubuntu 16.04 (Xenial 64).
I can see that I can run bash scripts as tasks, among various ready-made tasks.
By running a bash script I can see in the Ubuntu environment ansible is installed, because when typing sudo apt-get install ansible in the content of the task of type "Bash", then the output of the Logs of the execution of the pipeline says:
2018-10-22T16:33:00.7632392Z ansible is already the newest version (2.0.0.2-2ubuntu1.1).
From the Azure DevOps/pipelines documentation website there is no information regarding ansible, but the command is there indeed, and I can successfully run stuff like apt-get install, so I could even install it in case it was not there.
I am not able to specify the host (localhost) for ansible, not even changing the file /etc/ansible/hosts as sudo because I get back "permission denied".
Is it possible at all to run ansible playbooks in that DevOps/pipeline environment?
My idea was to:
- clone a git repository containing the "code to test with the pipeline" and the ansible playbook to configure the Ubuntu environment
- then changing directory to
/home/vsts/work/1/s/(it seems the Azure DevOps/pipeline user is calledvstsand when cloning a git repository then it goes to that~/1/s/directory) - then run an Azure DevOps/pipeline task of type "Bash" containing:
- an invocation of the
ansibleplaybook (to configure the Ubuntu environment) - an invocation of the
Makefilein the git repository (to run "the tests")
- an invocation of the
So far I've always got back "permission denied" when trying variations of:
sudo echo $(ifconfig eth0 | grep 'inet addr' | awk '{print $2 }' | sed 's/addr://g') >> /etc/ansible/hosts
ansible-playbook ci/prepare-vm/azure-pipeline-vm-setup.yml -vvvv --extra-vars "cli_input_username=vsts"
or trying to pass the eth0 IP address directly to the command ansible-playbook via the -i parameter
- Why it seems I can not run an ansible script even if the ansible package is installed?
- How can I run this ansible script in an Azure DevOps pipeline?