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
0 votes
1 answer
22 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....
0 votes
1 answer
32 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
25 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
1 answer
17 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 dont know the private IP address before hand. I have ...
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: ...
7 votes
2 answers
13k 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
222 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 ...
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 ...
2 votes
1 answer
78 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 ...
2 votes
2 answers
102 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 ...
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 ...
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 ...
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 ...
1 vote
1 answer
58 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
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 ...
0 votes
1 answer
179 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
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>...
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 ...
1 vote
1 answer
520 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
3k 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 ...
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 ...
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&...
0 votes
2 answers
348 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 ...
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 ...
1 vote
1 answer
1k 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
819 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 ...
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 ...
2 votes
3 answers
7k 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
1k 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 ...
2 votes
1 answer
5k 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
103 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
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 ...
4 votes
2 answers
20k 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
779 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
39 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 vote
2 answers
4k views

ansible filter debug output

I have the following output resulted from a shell command which is run on ansible on every host from my inventory: TASK [debug] ok: [10.240.22.44] => { "msg": { "changed": true, ...
8 votes
2 answers
54k views

Passing variables between scripts in a Jenkins pipeline

I have a declarative Jenkins pipeline that looks like the following: pipeline{ agent { ... } stages { stage("Provision EC2 Instance and Set ENV Variable"){ ...
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: ...
11 votes
3 answers
16k views

ansible: difference between a variable and a fact

While I'm using Ansible for quite some time, I'm not sure I really understand the differences between a variable and a fact. Would it be any difference doing - set_fact: nginx_ssl: /etc/nginx/ssl ...
0 votes
1 answer
137 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
383 views

Ansible role depend on other roles

I have a role, foo that installs a file {{ foo_path }} that's defined in roles/defaults/main.yml. I have a second role, bar that depends on that file being there. I could put foo in the roles/meta/...
1 vote
1 answer
64 views

Unable to login as `ubuntu` user on ec2 instance spawned from auto scaling group

Utilizing Ansible AWS modules, I'm creating an AMI from an existing EC2 instance where I am able to ssh with both my user and default account (ubuntu). After the AMI is in a ready state, I then create ...
0 votes
0 answers
230 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 ...
1 vote
1 answer
2k views

Why can't my playbook find the community.docker modules

I am trying to write a playbook that will download a docker image and run it on a group of servers. I have a python 3.6 virtualenv created and installed ansible into it. I then ran: ansible-galaxy ...
5 votes
1 answer
2k views

Ansible no user $HOME by default - so how do I run commands

I have thousands of servers that, by default, for security and space do not create a $HOME when you ssh in. This seems to be posing a problem for Ansible as it keeps trying to chdir to home that does ...
1 vote
1 answer
141 views

Use ansible to create GitHub repository with README

We use Ansible to automatically setup Kubernetes clusters. KPT https://kpt.dev/ is further used to deploy config files to pods in these clusters. In this process we need to create new GitHub ...
1 vote
2 answers
525 views

Why does Ansible ignore tasks after failing?

My ansible playbook has a task named 'Copy the build script to the system and run it'. It is prone to errors, so I've created a debug task to debug it: - name: Copy the build script to the system and ...
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 ...

1
2 3 4 5
9