Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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.

Filter by
Sorted by
Tagged with
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 ...
0 votes
1 answer
18 views

How to include a simple ansible vault file and refer its content from the whole ansible workspace?

I am thinking on a trival secret ansible vault: I have a secret.yml in my inventory, which is the single encrypted file in my ansible workspace, containing all the secret data. Its structure is very ...
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&...
0 votes
2 answers
582 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 ...
8 votes
1 answer
5k views

Ansible: Exclude a parameter if variable is not set

Is there a way to exclude a parameter entirely if a variable is not set? I do not want to use a default value for this, I simply do not way the parameter referenced at all. For example, --- - name: ...
2 votes
2 answers
5k views

Passing parameters from Jenkins to Ansible playbook

How can I pass parameters from Jenkins to my Ansible playbook? Eg. I want to take IP address from users and pass it to the playbook so that it will execute only on those machines.
1 vote
1 answer
30 views

How to manage lxd server configuration by ansible?

I am trying to set up the lxd global, server settings with ansible. Note, these are not the instance or container settings, these are the global settings of the lxd daemon. For example, core....
0 votes
1 answer
75 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 ...
1 vote
1 answer
62 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 ...
2 votes
1 answer
97 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 ...
0 votes
1 answer
43 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. ...
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, ...
0 votes
2 answers
37 views

Run Ansible win_shell without double quotes

Below is my script win_shell: 'C:\\TEMP\\myscript.ps1 -password {{ password }}' But when it executes, it get executed as below and as there is a dollar ($) in password its not working properly. "...
0 votes
1 answer
454 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: ...
0 votes
1 answer
156 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 ...
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: ...
0 votes
1 answer
35 views

How to determine the color of a shell script task in Ansible?

There are various Ansible modules which can execute my own-written script (ansible.builtin.script, ansible.builtin.shell, ansible.builtin.command). However, I would like to determine the color of the ...
1 vote
2 answers
947 views

Ansible - Configuring Supermicro servers via Redfish API

I plan to configure Supermicro servers via the Redfish API. Ansible provides the following modules for the Redfish API: community.general.redfish_command community.general.redfish_config Supermicro ...
0 votes
1 answer
2k 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 ...
0 votes
1 answer
224 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 ...
3 votes
2 answers
9k views

using copy module with wildcards

I need to copy a database backup file from a primary server to a standby server. Since I can't use synchronize, I was following this method: copy a file from primary to the local ansible server, copy ...
1 vote
1 answer
137 views

How to pass the result from one task (on one host) to another task (on another host) inside an ansible playbook?

I can't get this seemingly easy play to work: --- - name: Get the filename hosts: host1 tasks: - command: # find command that returns a filename register: filename - name: Use the ...
0 votes
1 answer
524 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 ...
1 vote
1 answer
449 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>...
0 votes
2 answers
420 views

Run dependencies only once in muliple plays in Ansible

I have a collection of roles that all depend on a common role: # roleA/meta/main.yaml dependencies: - role: common # roleB/meta/main.yaml dependencies: - role: common # roleC/meta/main.yaml ...
1 vote
1 answer
257 views

How can I put some set of machines to a group in an ansible inventory dynamically using the add_host ansible module?

I am trying to dynamically populate an inventory group called cloned_group in my current inventory . I passed the hostnames through the survey by the following names clone_machine_1, clone_machine_2, ...
4 votes
2 answers
5k views

How to store/retrieve multiple ansible-vault passwords within/from a single file

Update: As @yaobin pointed out. It appears they removed the part about the multiple passwords being in a single file. It was here as can be seen from web archive: https://web.archive.org/web/...
4 votes
1 answer
1k views

How to share variables across instances?

I'm writing TestInfra test scripts for mongo cluster instances using Molecule Ansible. I want to share variables across all the instances. I created a python class, and initialise and update the ...
2 votes
1 answer
47 views

Creating a cmd task with all the private ip address details collected from gather_facts

I am running an Ansible playbook from my local laptop to AWS connecting on the public IP address. The infra is being spun up by terraform so I don't know the private IP address before hand. I have ...
0 votes
0 answers
58 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 ...
0 votes
1 answer
125 views

Conflicts while building AWX-EE custom image

I'm currently building AWX EE custom image with the latest available but it seems latest versions got some conflicts with pip modules. My custom image was working great in July (awx-ee version 22.X 23....
7 votes
2 answers
14k views

Applying ansible playbook to a docker container on a remote host

I have automated the setup of several docker containers with ansible. This works pretty well but there are certain recurring tasks that have to be executed within the docker containers. It is possible ...
1 vote
1 answer
443 views

Using a different Python version in AWX

I updated a recent playbook module that says I need to use at least Python version 3.8. I run this playbook on our AWX controller. When I run the cmd module and do a "which python3" I get ...
2 votes
2 answers
192 views

Use an asymmetric cypher to secure Ansible vault

I'm trying to develop a Playbook which must handle sensitive user data (SSH keys, Registry credentials, etc.). Only a user and the Ansible controller can see the data associated with that same user. ...
1 vote
1 answer
2k views

Ansible playbook fails on Windows server

--- # This is a basic playbook for testing - hosts: WindowsSandbox #gather_facts: no vars: ansible_remote_tmp: c\temp remote_tmp: c\temp tasks: - win_shell: cd c:\temp ...
1 vote
1 answer
125 views

Ansible inventory for restart on worker node

I looking to execute a simple reboot via Ansible using its playbook - name: Worker-node Reboot hosts: node1 gather_facts: no remote_user: team become: true tasks: - name: Reboot the ...
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....
1 vote
3 answers
10k 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 ...
1 vote
1 answer
2k views

How to reload the Firewalld service using Ansible?

I have added some rules to firewalld on CentOS via Ansible. But I need to reload the firewalld daemon for the service to work properly and permanently. Is there a way to do this in Ansible? Here is my ...
7 votes
2 answers
5k views

Testing for EL with Ansible facts; distribution or os_family?

Sometimes in an Ansible playbook, you'll want to condition running a task on whether or not the distribution is CentOS, RHEL, etc, or if it's something else. A very common example is when a package is ...
1 vote
1 answer
2k views

Why is Ansible task getting stuck for so long?

I'm new to Ansible, I've made a playbook with only two tasks as shown below: - name: Installing Kubernetes for the master node connection: ssh hosts: x.x.x.x become_method: su tasks: - ...
3 votes
2 answers
946 views

How to use facts from one host to perform actions on another host?

In Ansible I'm trying to generate a variable from a task on one host and then use the variable to do something to another host. Specifically, I'm trying to create a Kubernetes cluster - On the control ...
2 votes
3 answers
8k views

Using `dig` Ansible module?

I am trying to look up the IPv4 address (a single one, which I will assert on!) for a given name using Ansible and use that as a fact "down the line". An MWE looks like this: --- # vim: set ...
0 votes
1 answer
3k views

Is there a way to declare global(?) variables inside an ansible task?

I have an Ansible playbook, this playbook has a role on it, this role is configured to run only on 2 hosts: yaml - hosts: node1,orchestrator1 gather_facts: True any_errors_fatal: True ...
4 votes
1 answer
10k views

Ansible: How to get hostname without domain name?

How to get value from /etc/hostname ignoring domain name. For example, /etc/hostname says "client.test.dom" and I need to get "client". I have tried "{{ ansible_nodename | ...
0 votes
1 answer
289 views

Ansible Connecting to remote Docker container over SSH

I have the following situation: I have a remote server that runs docker with a Postgres container. The Postgres instance is only reachable through a docker network, not directly from the remote server....
0 votes
0 answers
101 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 ...
6 votes
2 answers
25k views

Ansible temp dir change

Ansible version 2.9.2 Is it possible to change ansible temp dir for one playbook only? I have VMs with r/o root. So, the playbook fails. Even if I run my playbook under root user on target VM it can'...
0 votes
1 answer
2k views

how to run powershell script as windows administrator user using ansible

i want to run a power shell script on remote windows machine. The PowerShell script will install software on C drive. The user which used to login is already in administrator group. But when the ...
1 vote
1 answer
90 views

Why doesn't ansible.builtin.lineinfile behave as expected in this particular task?

I'm attempting to update /boot/firmware/cmdline.txt on a few Raspberry Pis to enable cgroup support. Seemed a good fit for ansible.builtin.lineinfile. The existing contents of /boot/firmware/cmdline....

1
2 3 4 5
9