Questions tagged [ansible]

Use this tag for questions about Ansible, an open-source automation engine, related to using Ansible for topics such as cloud provisioning, configuration management, application deployment, etc.

39 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
1 answer
1k views

Is there any way of getting code coverage with molecule?

I'm currently working on testing Ansible roles with Molecule. I have one role with 2 scenarios that are executed in Jenkins but just before that, those are submitted to a SonarQube analysis. So I ...
Yoiro's user avatar
  • 151
2 votes
0 answers
1k views

Ansible/AWS dynamic inventory -- How to create groups based on tags?

I am trying to create custom groups, based on tags. I am using this doc as a reference: https://docs.ansible.com/ansible/latest/plugins/inventory.html#inventory-plugins As a baseline, in my aws_ec2....
synth45's user avatar
  • 71
2 votes
1 answer
79 views

How to test production Ansible execution without having to provision target

We use ansible for our day to day operation and so far so good. We have been looking for a way to run local test etc just like chef guys and found molecule that we use with testinfra/vagrant. While I ...
black sensei's user avatar
2 votes
1 answer
897 views

How to programmatically generate docker-compose file?

I am writing an Ansible playbook to deploy services to a clustered environment. There are 3 types of hosts (Application, Load balancer, database). Services are deployed via docker-compose on each host ...
user2818782's user avatar
1 vote
1 answer
37 views

ansible_become has no effect despite the ability to execute sudo on GCP hosts

Say I want to execute the following command on target hosts (deployed on GCP): ansible all -a "head -1 /etc/shadow". The command demands the root access. With the default Ansible ...
SkogensKonung's user avatar
1 vote
0 answers
30 views

Implementing the right conditions for a yum command for centos5 in Ansible

I'm currently working with a centos5 host and I have to install some packages with yum. Unfortunately, as far as I know, centos5 doesn't support Ansible's yum module, since it requires python2 ...
Wander's user avatar
  • 11
1 vote
1 answer
367 views

How Can I Escape Backspace Using Set_Fact In Ansible With Jinja Conditional

I cannot figure out how to escape an HTML closing tag, <\b> in this example, when used inside an Ansible Jinja conditional (ansible 2.9.27 in this case). Using an additional backslash <\\b>...
alteredstate's user avatar
1 vote
0 answers
35 views

Is there a good/best practice for temporary changes in Ansible?

Sometimes, I need temporary changes in a playbook. Like adding a firewall rule, do things, and remove the firewall rule again. Or adding a local package repository mirror, install packages from it, ...
stackprotector's user avatar
1 vote
0 answers
23 views

Filtering included data for specific criteria to run tasks

I have directory with yml files in there which set parameters for different instances of the software I'm to deploy. It looks something like this: instance1: ip: 127.0.0.3 servername: mycoolserver ...
jhoffrichter's user avatar
1 vote
0 answers
32 views

Filter jobs by inventory

I'm using Ansible AWX and I'd like to find all jobs that were done for a specific inventory , I can do that by going to the inventory and then in the "completed jobs" tab, but is there a way ...
adaba's user avatar
  • 111
1 vote
0 answers
78 views

Ansible : 'NetworkManagementClient' object has no attribute 'private_endpoints'

I try to deploy a private endpoint for a storage account with Ansible. I am using azure.azcollection.azure_rm_privateendpoint. My playbook code is as below: - name: Create PE hosts: localhost ...
MoonHorse's user avatar
  • 111
1 vote
0 answers
59 views

Power on AWS EC2 hosts by specifying their ansible hostnames

I have inventoried my AWS EC2 hosts using the ansible Ec2 inventory plugin. I would like to be able to power on hosts that are currently powered off, by specifying hostname patterns in ad-hoc ansible ...
Life5ign's user avatar
  • 130
1 vote
0 answers
460 views

Docker mount volume on SELinux enabled server

I'm trying to run Nginx as the docker container on SELinux enabled server with mounted configuration as -v /host/path/nginx.conf:/etc/nginx/nginx.conf:Z That works fine till I will deploy updated ...
JackTheKnife's user avatar
1 vote
0 answers
20 views

Redirected `ansible-doc -s` output gets weirdly formatted

I'm preparing for Ansible certification, and I decided that ansible-doc -s may be useful to speed up creation of playbooks. It dumps a snippet of configuration of the requested module, with all ...
caxcaxcoatl's user avatar
1 vote
2 answers
2k views

Ansible fetch all vars files from a directory to generate a combined vars file

What I'm looking for is a task (or tasks) to read whatever .yml files exist in a specified folder and combine them into a file containing all the variables. For example: pets/steves_pets.yml: cats: ...
Sam's user avatar
  • 111
1 vote
3 answers
8k views

How can I check for an installed packaged version on multiple linux hosts?

i need to check more than 100 servers for the snapd package, but I don't like the output at all. I searched all day for different options without luck. Attached is the output of ansible-playbook. Any ...
Sissi_00_20's user avatar
0 votes
1 answer
26 views

Trying to Create a Docker Ansible lab and Cant SSH

I'm trying to setup a mini ansible lab with docker containers. I have 1 Rockylinux based container as the ansible controller, and then (for right now) 1 Rockylinux based container as the host. For ...
egkennedy93's user avatar
0 votes
0 answers
19 views

How to set up an "always/finally" node in an Ansible workflow template?

I have an Ansible Automation Platform workflow template and I want to add a job to report the completion status of the template to a REST API, whether it fails or not--similar to the Finally section ...
jeremywat's user avatar
  • 111
0 votes
0 answers
33 views

get no debug on why my role is not triggered from my ansible playbook

I have a Vagrant infra to test ansible roles. Here is my playbook luis@spinoza:~/proj/g/infra/mz_devops/vagrant/deb11$ more tests/playbook_test_doc.yml --- - name: Debug role path content hosts: all ...
user3313834's user avatar
0 votes
0 answers
36 views
+100

Is there an ansible command to configure a vmware host to synchronize time with the host?

I've been searching the docs for a bit, but is there a way in ansible - either the rest api or the built-in api - for vcenter to configure a host that has vmware tools installed to synchronize its ...
Peter Turner's user avatar
  • 1,376
0 votes
0 answers
52 views

Identifying worker nodes from Ansible inventory group which are not yet joined to k8s cluster using ansible.builtin.regex_search and regex_replace

I am using Ansible to configure a k8s cluster with several nodes. I have a playbook which checks if a variable representing the kubeadm join command has already been defined. If it has not, it ...
Jehan Alvani's user avatar
0 votes
1 answer
41 views

How can I log every command for which an Ansible playbook uses elevated permissions?

I have an Ansible playbook that runs against a Linux target host and uses become to gain elevated permissions for those actions that require it. For auditing purposes, I need a list of all the Unix ...
jstarek's user avatar
  • 123
0 votes
2 answers
351 views

why does my Ansible playbook throw "Found existing installation: requests 2.25.1\n\n:stderr:ERROR: Cannot uninstall requests 2.25.1"?

I'm trying to run an ansible playbook that installs docker and docker-compose and runs a compose file on a ec2 t2.micro. To use the docker modules in ansible, I need to have docker and docker-compose ...
Keshav Singh N's user avatar
0 votes
1 answer
180 views

Unable to create a project with MANUAL as source in AWX

I have followed the instructions to install AWX from this site. https://computingforgeeks.com/install-and-configure-ansible-awx-on-centos/ But I'm unable to create manual SCM project on new project on ...
Siva's user avatar
  • 223
0 votes
0 answers
232 views

Update apt cache from ansible when user is different from root

I have the following Dockerfile I'm using to test my ansible playbook. FROM ubuntu ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install -y git software-properties-common ansible ...
Gianluca's user avatar
  • 101
0 votes
0 answers
53 views

Is there a way to include a role once?

Suppose there is a relatively basic role that is a prerequisite for other roles, but not basic enough to be just included everywhere. The dependent roles could use ansible.builtin.include_rule, but ...
Helmut Grohne's user avatar
0 votes
0 answers
39 views

How to manage ports using proxycommand and ansible

Sometimes when I'm using ansible against a fairly large number of hosts (around 100) about 3-5 of them jump to a completely different host. These devices are all connected via proxycommand using ...
Peter Turner's user avatar
  • 1,376
0 votes
0 answers
95 views

ansible action plugin execute some modules once

I stumbled across following problem creating custom python ansbile action plugin: how to execute some modules once (i know in yaml it is possible to set run_once and delegate_to)? For example having ...
Tautvis's user avatar
0 votes
0 answers
319 views

Unable to install Jenkins plugin via ansible

I've been trying to use ansible to install Jenkins and then once Jenkins has been installed, use the jenkins_plugin module to install the build-pipeline-plugin into it. Here's my code (also hosted on ...
AjB's user avatar
  • 103
0 votes
0 answers
33 views

Ansible Tower / AWX - Job Execution when Instance Fails / becomes unavailable

I have queries on the Ansible Tower/ AWX job execution. While a playbook is under execution. Let's assume this is a lengthy list of tasks and below are the two scenario. This is more on towards ...
Koushik Padmanaban's user avatar
0 votes
0 answers
341 views

ansible win_copy cannot copy src file as it does not exist

I am trying to run a molecule test where it is supposed to create a VM and copy a binary from network UNC path to the VM but somehow it is failing with the below mentioned error. This is what the task ...
WindowsGuy's user avatar
0 votes
1 answer
1k views

ansible fatal: "sudo: a password is required", even after priveleges are escalated

while trying to setup a remote machine using ansible, I am running into the following issue: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n&...
vinylic's user avatar
0 votes
1 answer
1k views

Ansible / Jinja2 Unexpected templating type error

I am trying to take a dictionary from one or more async tasks "register: task_variable" then collecting it as a list based on its id's and running a wait task using async_status on the ...
Cyber Axe's user avatar
0 votes
0 answers
706 views

AWX Ansible - Can't access repository Git and Bitbucket

I have configured and successfully used until some days ago a project in AWX, synchronizing it with a Bitbukcet repository. Now, when I am trying to sync the Project with the repository, I get this ...
SctALE's user avatar
  • 101
0 votes
0 answers
26 views

What is the best approach for managing this local network of SBCs?

I am dealing with hundreds of SBC's (Raspberry Pi or similar). They are all networked to a central control PC via ethernet. I need to automate the following: Perform a network OS install Perform ...
A__'s user avatar
  • 101
0 votes
0 answers
243 views

How to use Ansible to create a Nexus npm repo

I need to use Ansible to create an npm repo in our Nexus server. I've been looking through the Nexus REST API documentation and figured that I would use the uri module to issue the relevant command(s) ...
Rob Wells's user avatar
  • 123
0 votes
1 answer
193 views

How to keep packages updated and keep in pace with security updates

In a project with multiple vms that run various applications from Wordpress to Django and various other things. Is there a way or a tool to keep track of the packages that require updates or have ...
user3224454's user avatar
0 votes
1 answer
31 views

ansible network automation: log commands all commandes from mutiple plays

Trying to write a script to publish basic configurations for any futur new devices. Also assert compliancy of basic configuration for devices in production. Trying to gather all the lines executed, on ...
tintin's user avatar
  • 81
0 votes
0 answers
1k views

Ansible in venv: how to pip install globally on localhost?

Ansible is installed and is running in a virtual environment: (env) ansible-playbook -vvvv -i localhost playbook.yml I'm trying to install a Python package globally, but it either installs in venv ...
waverider's user avatar
  • 109