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
92 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
1k 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
53 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
0 answers
39 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
35 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
85 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
62 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
500 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
22 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
0 votes
1 answer
116 views

Ansible - 'loop' requires a list and got a list, but doesn't work

Minimal reproducible example: role/defaults/main.yaml: node_sysctl: kernel.shmall: 197951838 kernel.shmmax: 810810728448 kernel.shmmni: 4096 role/tasks/main.yaml: - name: Tune sysctl sysctl: ...
adoring_ellis's user avatar
0 votes
1 answer
30 views

How to design an ansible workflow over multiple hosts?

I am new to ansible and I am wondering how I should design my workflow with ansible in an ansible kind of way. The Task: I have a workflow/process (not ansible yet) for setting an application up. ...
Mike's user avatar
  • 1
0 votes
0 answers
72 views

Using `synchronize` in Ansible provisioner (Vagrant): "ssh: Could not resolve hostname default: Temporary failure in name resolution"

I'd like to perform a very basic task with Ansible: rsyncing a local file to a server (here: local vm). For this, I've installed ansible / vagrant / virtualbox, and created the following minimal ...
Andrey Tyukin's user avatar
0 votes
0 answers
32 views

Setting up winrm connections with dynamically created inventory group using ansible add_host module

I am trying to establish WinRm connections to a set of windows machines to automate a cloning task(windows vms) using ansible automation platform. I populated an inventory group called cloned_group ...
Kavisha Abeynayaka's user avatar
0 votes
0 answers
38 views

How to copy a powershell script from a SCM repo to a windows machine through vmware_vm_shell ansible module

I wanted to execute a powershell script to add a local user to a windows machine without using a winrm connection. Hence i tried to copy the file from the scm repo to the windows vm and run it .I ...
Kavisha Abeynayaka's user avatar
0 votes
0 answers
27 views

Can I set a Packer provisioner attribute only if a var is provided?

I'm using the AWS builder and Ansible provisioner. If I packer a -var app_version=latest, I'd like to add the key and value as an AWS tag and/or pass to Ansible as an --extra-vars. If no value is ...
8None1's user avatar
  • 121
0 votes
0 answers
88 views

Ansible-Playbook to install Kubernetes cluster gives GPG error

For my virtualisation class, our lab assignment at the moment is to create a kubernete's cluster with 3 VM's / Nodes. I have a fourth machine where i installed ansible on that sends all correct ...
user42818's user avatar
0 votes
1 answer
111 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
40 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
  • 133
0 votes
0 answers
39 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
56 views

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,430
0 votes
0 answers
94 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
57 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
497 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
383 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
289 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
87 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
1 answer
2k 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
864 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
292 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
212 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
36 views

Ansible network automation: log all commands from multiple plays

I'm trying to write a script to publish basic configurations for any new devices. Also to assert compliancy of basic configuration for devices in production. Trying to gather all the lines executed, ...
tintin's user avatar
  • 91
-1 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
  • 107