Questions tagged [ansible-playbook]

468 questions
1
vote
1 answer

Ansible host "unreachable": true

I just started learning the basics of Ansible. And facing some problem related to server connectivity via SSH. I created a folder named publich_html and put my code into that folder and changed the permission. When I try to execute my playbook it…
Ali Warrich
  • 21
  • 1
  • 2
1
vote
1 answer

how to store value of ansible fact variable in another variable

I wanted to store value of ansible fact variable in some other variable, and also wanted to check is that fact variable is empty or not Below is my code where i can print the value of ansible_local fact variable but i wanted that value to store in…
Huzefa
  • 65
  • 4
  • 13
1
vote
1 answer

How to pass Variable from previous host to next target host play in ansible playbook

I want to pass variable called ssh_user from the first play on ansible playbook to next different host play. I have tried to use "set_fact" but seems like it's still can't retrieve variable from the previous play. Below is my ansible playbook…
1
vote
1 answer

Ansible send hostnames in a list to python script

I wanted to send the hostnames from ansible role to python script. In my host file there are 2 hosts 1ld900 and 1ld901. my role as below --- - name:execute python script: writetoexcel.py {{ ansible_play_hosts_all | join(" ") }} …
user984993
  • 23
  • 3
1
vote
2 answers

Ansible : Loop inside loop

On ansible [core 2.13.3] my var.yml file is like this : vlans: Servers: vlan_id: 10 ip: 192.168.22.20 mask: 255.255.255.0 mode: tagged: 1/1,1/2 untagged: 1/3 Clients: vlan_id: 20 mode: tagged: 1/1,1/3 …
user5525652
  • 157
  • 1
  • 4
  • 14
1
vote
1 answer

Ansible to a Cisco Router :: Password Message Messing Up the Connection?

When I manually SSH from my Ansible server to a Cisco router, I see this on the command line: me@ubuntu01:~/ansible$ me@ubuntu01:~/ansible$ ssh user01@10.10.10.101 Password: ####################### Cisco Router 101 ######################## Hi,…
Pete
  • 131
  • 6
1
vote
1 answer

Safely abort Ansible playbooks when server downtime runs out

Afaik ansible offers no possibility to safely exit a running playbook, so I am wondering which strategy would be wise to not leave hosts in inconstistent states: Lets picture an infrastructure of ~300 database hosts and a weekly downtime of only few…
1
vote
1 answer

Ansible playbook can not connect to remote user through ssh => unreachable & permission denied

I'm building a complete solution to setup and harden our vps (ubuntu 22.04) with bash script and Ansible playbooks. What I want to do is the following: Create a custom group "sudogroup" with sudo privileges Create a new user "sudouser" in this…
1
vote
2 answers

Ansible Loop Through Variable Number of Hostvars

I am trying to grab hostnames and IP addresses from a user-entered list of hosts and send that information to a central server. The primary issue I'm running into is that the number of hosts can vary considerably. E.g. on the first run a user may…
hypen9950
  • 13
  • 1
  • 4
1
vote
1 answer

Create parameters from a list of lists

I have a fact, which is a list of lists, e.g. [ [disk1, filename1], [disk2, filename2], ... [diskN,filenameN] ] I need to run a command in the format like command -x disk1,file=filename1 -x disk2,file=filename2 ... -x diskN,file=filenameN I can't…
Billy K
  • 121
  • 1
  • 3
  • 16
1
vote
1 answer

Fan out to other hosts when already using Serial in ansible

I have 80+ hosts that run my application, and I'm updating a long existing ansible playbook to change our load balancer. In our current load balancer setup, hosts can be added / removed from the load balancer in one ansible play by shelling out to…
Mike
  • 113
  • 3
1
vote
1 answer

Need to know more about the handlers in ansible

Below is the tasks I have in my nginx role # tasks file for nginx - name: Backup and update nginx configuration file template: src: templates/proxy.conf.j2 dest: "{{ nginx_conf }}" backup: true owner: root group: root …
1
vote
1 answer

Syntax error in ansible while using handlers

Below is my role task which copied the nginx conf and then reloads the service only when the shell command output of nginx -t contains "syntax is ok" --- # tasks file for nginx - name: Backup and update nginx configuration file template: src:…
1
vote
1 answer

How can I loop over files in a directory and move only the unique files using ansible

I’m trying to loop over all files in a directory, these files are named differently but should have the same contents. Is there a way to loop through all these files using ansible and then move the unique files into a different directory. Thanks in…
Adam
  • 31
  • 1
  • 4
1
vote
0 answers

Ansible EdgeOS "add" issue

I'm trying to create a playbook to update a few edge routers to current hotfixes, but I cannot find a way to get around the prompted yes/no question with the supported community.network.edgeos_command module parameters (wait_for, interval, commands,…