Ansible version: 2.8.3 or Any I’m using -m <module> Ansible’s ad-hoc command to ensure the following package is installed –OR– let’s say if I have a task to install few yum packages, like (i.e. How can I do the same within a task (possibly when I’m not using ansible’s shell / command modules): It works, but how can I get
Tag: ansible
Reliably targeting correct Azure Managed Disk on a Linux VM using an Ansible playbook
How do I reliably partition and mount the file system of an Azure Managed Disk on a Linux VM using Ansible playbooks? I can create an Azure Managed Disk with azure_rm_manageddisk and assign it to a VM instance. My issue starts when I’m trying to take the disk into use. I just don’t know how to reliably target the correct
The best way to authorize ssh key of each node to all nodes in the cluster
I want to create a cluster infrastructure that each node communicates with others over shh. I want to use ansible to create a idempotent playbook/role that can be executed when cluster initialized or new nodes added to cluster. I was able to think of 2 scenarios to achieve this. First Scenario task 1 fetches the ssh key from a node
find the latest file that was modified within last minute in ansible?
I have a list of files in a particular directory as shown below: Each file name ends with timestamp in it. Now I need to find one latest file which was modified or created just a minute back in ansible. If there is no file like that then return successfully from the ansible by logging “cannot find any file” if
Can’t assign password to user with ansible user module
When I run this it does what it’s supposed to do. It creates the user and the home directory that I specify. It also prints out a password and the hash but I can’t log change to this user no matter what I do. Any suggestions on how I can get a password assigned to this user correctly would be
Is there a way to sort the groups in an ansible host file without sorting the hosts within the groups?
In an ansible host(or inventory) file, you can group host using brackets. I want to sort these groups using sort function in linux but it will sort the individual hosts, and I want the right host to still be under the correct group. For example, I’m looking for a way to sort by group while keeping the host under the
Iterating Ansible setup command
I want to use ansible setup module to retrieve hosts specs and I tried with a bash for loop. Ansible version: 2.4 My hosts inventory has been defined in a group of machines which I called rhelmachines I would like to collect the following list of variables called “specs” I am then trying to include the ansible command in a
How to remove temp file in ansible using copy module
I’m using adhoc command for example After copy in the remote host. I found temp files in the directory ~/.ansible/tmp How to remove this temp directory on remote host? Using another module like “commmand” ? In the reference of copy ansible module i did not found about remove temp file after copy. Answer ~/.ansible/tmp is a “working” directory for Ansible
Pass bash script arguments to ansible command in script
I’m trying to run this command from a bash script and pass the extra-vars from the bash arguments. I run the script like below and get this error: I even tried escaping the quotes but it didn’t work. How can I get this to run? Answer Or, you can change your script to use $*:
Using register with a loop in Ansible
i want to code a playbook which IF a user exists changes the pw of it. The playbook should be able to take n User’s and change the pw of those Users. At the moment im having the issue that the when is empty due to the loop, i tried using with_items: {{ user_exists.results }} but this is somehow not