Questions tagged [ansible-playbook]

468 questions
0
votes
2 answers

Ansible module returns non json data

Ansible Azure module returns the data in a weird format Double single quoted characters. ''network_interface_names'': [''Ubuntu915''] As a result I can't use this anywhere to filter other resources. Any idea what can be done to fix this or make it…
user630702
  • 495
  • 10
  • 32
0
votes
1 answer

No package matching 'php7.2' is available

I am trying to install php with ansible but can don't know what is going wrong. this is my ansible file --- - apt_repository: repo: "ppa:ondrej/php" update_cache: yes - apt: name: "{{ item }}" install_recommends: no state:…
0
votes
0 answers

Change ifcfg-eth* files

I would like to determine the interface name of the hosts where ansible connects and use it as a variable, but the final goal is to create an ifcfg file config for every network interface on every host in the inventory. The problem is that I have…
0
votes
1 answer

Ansible: Why cannot I get debug output

I have the following playbook, and I'd like to get the debug oupput: --- - name: Install and configure chrony hosts: '{{ hostgroup }}' gather_facts: no become: yes become_method: sudo tasks: - name: make sure chronyd is installed …
sebelk
  • 682
  • 4
  • 13
  • 32
0
votes
2 answers

using logical operator && to validate condition in Ansible

i would create a playbook that Check configured filesystems for TSM configuration I need to echo "${FS_TSM[@]}" from register: FS_TO_ADD and to conclude it, a conditional must be set to debug the FS_TSM [[ ! -z "${FS_TO_ADD}" ]] && { FS_TSM+=(…
medisamm
  • 1
  • 1
0
votes
2 answers

Automatic way to find where variables are coming from in Ansible

Whenever I have to change something in our Ansible repository, I have to check all the places where a variable could be set and that's very time consuming. Is there something that would show me something like "the varialbe X being used in this…
gtirloni
  • 5,746
  • 3
  • 25
  • 52
0
votes
1 answer

Ansible | conditional statements should not include jinja2 templating | when group_name variable

I have a simple ansible main_task.yml file which is looped from a main.yml . inventory.ini [port_22] 192.168.0.189 192.168.0.199 [port_222] 192.168.0.199 [port_888] 192.168.0.200 main_task.yml --- - name: "run this on {{ item }} hosts" debug:…
0
votes
1 answer

Write original Ansible variable to xml file

I'm trying to find a way to write the original {{ ansible_host }} var in to a xml file. This variable will replace a static IP in a device config. The reason that I want to replace this IP with the original variable in the file, is because later in…
Collega
  • 65
  • 6
0
votes
1 answer

Ansible playbook error

Hi I have just started learning ansible. I am trying to write playbook as: vpc-setup.yml which including hosts: localhost connection: local gather_facts: False tasks: - name: Import VPC Variables include_vars: vars/vpc_setup.md - name: Create…
0
votes
1 answer

Ansible - No such file error when activating systemctl Podman user socket

I am running an Ansible playbook on a fresh Oracle Linux 8 system. It includes a step where it asks systemctl to activate a user Podman socket like so: - name: Enable podman socket vars: userid: ansible_facts.getent_passwd.{{ ansible_user_id…
hpy
  • 845
  • 3
  • 18
  • 28
0
votes
1 answer

match item.x value with inventory_hostname

I need some help with matching inventory_hostname with item.host (from vars_file). What is the best way to do that? I couldn't figure out this as i am a newbie. My requirement is: I must call all hosts from inventory file. I must match item.host…
Atif
  • 11
  • 1
0
votes
1 answer

Ansible playbook with extra checks

I'm trying to automate our patching and stumbled upon Ansible. I have ran the win_update module and this could be used for 80% of our servers, but others have a reboot procedure. Some groups of our servers need to be updated/rebooted in order,…
MeMario
  • 65
  • 1
  • 7
0
votes
0 answers

referencing variables from defaults/main.yml in ansible role

I have a role setup as follows roles/test/task/main.yml - name: Generate people files template: src=test.j2 dest=/tmp/{{ item.name}}.cfg loop: "{{people}}" roles/test/template/test.j2 First Var: {{ item.var1 }} Second Var: {{ item.var2…
pizzaguy39
  • 1
  • 1
  • 1
0
votes
1 answer

directory owner permission does not get updated properly via ansible loop

I am trying to create and update directory permission on my linux machine by using below ansible task but it does not change the ownership properly: for instance: directory /home/xyz/xyz/{{ IDM }} and /home/{{ IDM }} ownership permssion gets…
Roushan Jha
  • 55
  • 1
  • 1
  • 5
0
votes
0 answers

ansible: trigger same handler from multiple roles at the end of the playbook

My ansible playbook includes several roles, for example dovecot, postfix, postgres and rspamd. All of them require SSL certificates, which are generated by the certbot (lets encrypt) role. For this reason and for easier handling all roles follow the…
Volker Raschek
  • 347
  • 1
  • 5
  • 17