Category "ansible"

How to filter out a particular line from ansible output

I am facing an issue while running my ansible-playbook to filter out the IP address from the playbook output. Here is my code - hosts: myhost tasks: - nam

Change Ansible key in a dict

I have a dictionary in Ansible. my_dict: key1 : value1 key2 : value2 key3 : value3 key4 : value4 I would like the final output to be my_dict: key

Delete all old files, but keep newest 4 files using ansible-playbook

I would like to delete all old files, and keep newest 4 files. The output isn't what i expected. Even i use absent on file modules, but it doesn't delete the fi

Provisioning with Ansible and Vagrant multiple vagrantfiles

I'm creating a monitoring environment that has monitoring_servers and monitored_boxes, and of course Ansible controller. For testing roles etc I've created a n

Unable to perform "git clone" on local system using Ansible

I am trying to clone a git repo on my local system. I have done this manually and it works fine, but when I try to do it via Ansible, it doesn't work out Here i

VirtualBox silent install via Ansible fails?

$ ansible --version ansible 2.10.8 Per Oracle VM VirtualBox 6.1 Silent Install (How-To Guide), I should be able to install VirtualBox silently like this C:\tem

VirtualBox silent install via Ansible fails?

$ ansible --version ansible 2.10.8 Per Oracle VM VirtualBox 6.1 Silent Install (How-To Guide), I should be able to install VirtualBox silently like this C:\tem

Order of notify handlers

I have a task: - name: uploads docker configuration file template: src: 'docker.systemd.j2' dest: '/etc/systemd/system/docker.service' notify:

Ansible AnsibleUndefinedVariable no attribute

I have the following files vars/main.yml testconfig: - {hostname: router123, example: no ip cef} cisco_891_l2interfaces: - FastEthernet0 - FastEthernet1 -

How do I create an Ansible "pre-handler" that runs before the task but only if the task needs to run?

How do I create an Ansible "pre-handler" that runs before the task, but only if the task needs to run? In other words, Ansible will first check if the task need

Check if arrays are defined and not empty in ansible

I have the following code - set_fact: MY_HOSTNAME: "SOME VALUE" MY_SERVER: "00.00.00.00" - name: Get MY server set_fact: MY_SERVER: "{{ groups[MY

How to prompt user for a target host in Ansible?

I want to write a bootstrapper playbook for new machines in Ansible which will reconfigure the network settings. At the time of the first execution target machi

How to generate variable using ansible parameters like args, slurp, register and set_fact inside a doit task?

I am creating a doit task where I need to use ansible parameters like args, slurp, register and set_fact inside the task within actions to make sure the variab

Append a string to a List in Ansible

I'm trying to append a string to a list in ansible , so basically i'll be building a payload to delete few of the topology records in the F5 GTM network gear. I

ansible playbook error was: ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' although the module is installed

After upgrading ansible to version 2.10.5 and python3.8.10 my playbook.yml fails with this error. ModuleNotFoundError: No module named 'azure.mgmt.monitor.versi

Ansible change all dict key values only by filters

I have an ansible dict like ports: webui: 7200 webadmin: 7209 core_api: 7201 stock_api: 7204 import_export: 7207 And i want to transform all keys i

How can I get the installed apt packages with Ansible?

I am trying to list all installed packages on my Debian 7 (Wheezy), 8 (Jessie), and 9 (Stretch) machines. There are easy ways dealing with it using APT or

How to run a task when variable is undefined in ansible?

I am looking for a way to perform a task when ansible variable is not registers /undefined e.g -- name: some task command: sed -n '5p' "{{app.dirs.include

Ansible when condition: only run the script if the command failed

I would like a bash script to run only if the command run into an error, yet I am not too familiar how to use the when condition, can someone please help? gaiac

Issue in placing DataDog log annotation on deployment via ansible

I am using ansible version 2.7 for kubernetes deployment. For sending logs to datadog on kubernetes one of the way is to configure annotations like below, tem