Questions tagged [ansible-playbook]
The ansible-playbook tag has no usage guidance.
403
questions
0
votes
0
answers
3
views
Ansible AWX - ansible-playbook command not found
For some reason I'm getting the following error ansible-playbook: command not found. I logged into the server and I can run the ansible-playbook command.
sh-4.2$ ansible-playbook
usage: ansible-...
0
votes
0
answers
18
views
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 ...
0
votes
1
answer
138
views
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
---
- ...
0
votes
0
answers
18
views
Could not find imported module support code for freeipa.ansible_freeipa.ipaclient_test
My ansible controller is running on a Rocky 8.5 machine with the ansible-freeipa version 0.3.8-1.el8 rpm package installed.
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module ...
0
votes
1
answer
22
views
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 ...
0
votes
0
answers
24
views
Search and list AWX-Inventory in a playbook
I need help with Ansible AWX Inventory. We have many/different inventories on our AWX server which we are importing through different methods.
I have a requirement to search and fetch inventory names ...
0
votes
0
answers
31
views
Ansible: linked second playbook is not able to run a script for variables passed from multiple hosts from the first playbook
I am using 2 playbooks linked, there details mentioned below.
playbook1: collect raw data from multiple machines
- hosts: target_1
gather_facts: false
tasks:
- name: Register a new value
...
0
votes
1
answer
29
views
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
...
0
votes
0
answers
43
views
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:...
0
votes
1
answer
38
views
issue with playbook script
How can I write a playbook to
Make sure both NFS server and client listen to same domain in /etc/idmapd.conf and confirmed with nfsidmap -d
[General]
Verbosity = 0
Pipefs-Directory = /run/...
0
votes
0
answers
19
views
Ansible-playbook loop issue
I have a playbook that works great when I limit to a single host.
ansible-playbook -k playbook.yml group1
I need to be able to run it against multiple hosts at the same time. The syntax would be:
...
0
votes
1
answer
155
views
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 ...
0
votes
1
answer
40
views
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 ...
0
votes
0
answers
207
views
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
...
0
votes
2
answers
284
views
Make a skipped task show as "OK"
I have some ansible tasks that are run in two parts. The first part sets a condition, and the second part uses when to conditionally execute. Pseudo-example:
- name: check if installed
command: (...)...
0
votes
1
answer
789
views
I am getting an error in the ansible playbook
I am trying to learn ansible and I have coded my first playbook but it gives me the error saying
ERROR! A playbook must be a list of plays, got a <class 'ansible.parsing.yaml.objects....
3
votes
2
answers
1k
views
Iterating through nested list / dictionary using Jinja2 templates
I'm trying to dynamically configure multiple NFS servers in my system by generating their /etc/exports files using Ansible. I'm hoping to be able to do this with a jinja2 template. It's the jinja2 ...
1
vote
1
answer
1k
views
How to loop an array variable in Ansible
I have below task and I am failing to add the loop for the array variable.
ShopID is defined as an array inside group_vars. My aim is to call each variable one by one.
- name: Create directories with ...
0
votes
1
answer
28
views
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 ...
0
votes
0
answers
128
views
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 ...
0
votes
2
answers
129
views
Best way to create yaml files that have a variable number sections based on host
I am trying to use ansible to deploy configuration files out to hundreds of machines in which different machines will have multiple iterations of specific configuration snippets. Specifically I am ...
0
votes
1
answer
46
views
ansible registering variable outputs undefined variable
I'm trying to do this playbook for half a day. I'm using stat module to check sha1sum of file and if it is not equal to second file it should replace correct file.
But while registering some variables ...
-1
votes
1
answer
33
views
ansbile template weird formatting
I'm trying to create yaml based configuration files. Everything is working except that the lines after a loop is being indented for some reason.
So when I have this...
- job_name: {{ ...
1
vote
2
answers
168
views
selected hosts in inventory based on subset of name in ansible
I'm fairly new to ansible so maybe this is easy to do.
We have a large number of devices that have a consistent naming convention among different environments.
app0[01:25].dev.domain.com
app[01:25].qa....
1
vote
1
answer
64
views
Playbook containing unsafe variable values breaks after upgrading from ansible 2.10 to ansible 2.12 (from ansible 5)
I have upgraded my ansible setup from ansible 2.10 to ansible 2.12 (from ansible 5) using homebrew on Mac OS.
Since then a playbook has stopped producing working results.
- name: Assemble consul ...
0
votes
1
answer
246
views
Getting error AnsibleUndefinedVariable: 'facter_ipaddress_eth1' when running ansible playbook
Getting one big error stacktrace of ansible variable not found exception
ansible.errors.AnsibleUndefinedVariable: 'facter_ipaddress_eth1'
while I am runing ansible play book.
the value that gets set ...
0
votes
1
answer
139
views
Ansible blockinfile module - insert insert lines of code
I try to insert lines of code (shell script) with Ansible blockinfile module.
name: Customized prompt
blockinfile:
path: /etc/profile.d/customized_prompt.sh
create: yes
block: |
#!/bin/bash
# ...
0
votes
0
answers
65
views
jenkins job to deploy latest version in new env, using the deployed version
I have a jenkins job with multiple applications, each with 4 environment namely DEV, TEST,QA and PROD. I am using ansible playbook to deploy the artifact in each environment. I have deployed an ...
0
votes
0
answers
673
views
Ansible- Define variables based on conditions with if elif else
I have multiple roles as follows : haproxy, java, nginx, tomcat
├── ansible-test-host.yml
├── hapoxy
├── java
├── myplaybook.yml
├── nginx
└── tomcat
Base playbook is : myplaybook.yml and looks like ...
0
votes
1
answer
133
views
ansible AND operation with WHEN is failing when using ansible_facts
Team: I am trying to fail a task when two conditions are not met on a node. ansible_facts['distribution_version'] and ansible_facts['distribution'].
I am passing in two nodes. one node is 20.x ubuntu ...
0
votes
1
answer
180
views
How should i write the yaml file for use in ansible variable?
I started to deploying an ansible server, and i was trying to create 5 users in the client hosts, through a playbook (add5userslist.yaml), with a loop that uses variables in a list from another file (...
0
votes
1
answer
895
views
Ansible: How force kill process and exit from ansible-playbook if not successful?
I have two bellow tasks as part from my playbook
- name: "Verify httpd.service no running on node {{ ansible_hostname }}"
shell: "ps -ef | grep httpd"
...
0
votes
1
answer
287
views
Ansible playbook rebooting the server , wait till reboot complete
I'm facing a issue while executing shell script with ansible playbook.
Issue: I'm losing a connection with remote server because shell script is rebooting the server.
My Ansible playbook
- name: ...
1
vote
2
answers
88
views
Hide my password in Ansible Playbook
I would like to run mysqldump in the Ansible playbook by the shell module. Trying to find a way to hide my MySQL root password in the ansible playbook or Ubuntu.
I currently have a file that was ...
0
votes
1
answer
83
views
Ansible playbook - defining var based on condition
I want to create a var based on condition so I created the below :
hosts: test
vars: vtarget_backup_folder_in_progress: "{{ "{{ folder }}/{{ target }}/test{{ hostvars['localhost']['tstamp']....
0
votes
1
answer
99
views
How to make Ansible run batch of tasks on Cluster Node's - node by node
I have an ansible playbook which looks roughly like the following.
I need Zero Downtime Upgrade start and Zero Downtime Upgrade completed steps. will run once to put\remove cluser into upgrade mode.
...
0
votes
1
answer
803
views
Ansible conditional with variables and wildcards
Been trying to add a conditional with a wildcard and an Ansible variable and getting an error message. The idea is to trigger the api request with the container name starts with "android-", ...
1
vote
2
answers
255
views
Ansible filter using ad-hoc command
How can I filter the nocache block or free block using ad-hoc command? I tried ansible centos1 -m setup -a 'filter=ansible_memory_mb.nocache' but doesn't filter it out.
ansible centos1 -m setup -a '...
0
votes
2
answers
347
views
ansible main.yml if else conditionals
So I'm running an ansible role which has a file main.yml in the defaults/ role folder. The content of that file is this:
---
api_secrets:
'API_PROFILE': "{{ api_profile }}"
'...
0
votes
1
answer
992
views
Create multiple directories with mode and loop via ansible
I'm trying to play with loop and ask in a playbook to ansible creating multiple directories on a server with specific attributes : mode owner group .
I think i'm close but don't get it working.
I get ...
0
votes
0
answers
93
views
ansible-playbook: command not found when running bash with cron [duplicate]
Running on ubuntu18, have a bash job to collect data from a router using ansible.
Here is the bash script
#!/bin/bash
cd ~/datacollect
ansible-playbook -i /home/user/datacollect/hosts /home/user/...
0
votes
1
answer
93
views
Ansible copy module - how to update file with an existing 'i' attribute?
I have a task in my playbook which should copy some files to a target directoy
The files should have an 'i' flag upon completion, so I set the attributes parameter of the copy like attributes: +i
this ...
0
votes
1
answer
1k
views
Ansible jinja2 template from JSON format provided as extra-vars
I have this jinja2 template:
# {{ ansible_managed }}
{% for vhost in nginx_vhosts %}
{%- if vhost.name == item.name -%}
# redirect www to non-www
server {
listen {{ nginx_port }};
listen [::]...
0
votes
1
answer
523
views
Hostvar syntax cannot receive extra variable as hostname
I'm is trying to use an extra vars to set the hostname in the "hostvars" variable to get the uuid from other host. But it seems that don't catches the variable's value.
This is the run line:
...
0
votes
1
answer
321
views
Ansible - Could not print value of custom fact
This is a playbook part of a role that talks with vmware.
I'm is trying to set a custom fact (target_vm) that receive the virtual machine name.
But when I Print it's value with the debug module it ...
0
votes
0
answers
108
views
Ansible sudo su get error "atal: [test1]: FAILED! => {"msg": "Timeout (62s) waiting for privilege escalation prompt: "}"
I have the below ansible script whre it got failed
- name: Download Java to Latest Version
become: yes
become_method: sudo
become_flags: su
become_user: root
shell: |
...
1
vote
1
answer
46
views
Custom fact does not receive value
This is a playbook part of a role that talks with vmware.
I'm is trying to set a custom fact (target_vm) that receive the virtual machine name.
But when I Print it's value with the debug module it ...
1
vote
1
answer
208
views
How to get extra vars java link and download it in ansible and extract it
I want to download java from http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
then extract it
tar -xzvf jdk-8u131-linux-x64.tar.gz
but ...
0
votes
2
answers
227
views
Ansible: Pbrun not able to execute
I have the below inventory file
[server]
abc.com
[server:vars]
ansible_user="user1"
ansible_ssh_pass="pwd"
ansible_pbrun_exe="pbrun"
ansible_pbrun_password="pqa"...
0
votes
1
answer
456
views
Add new disk to LVM group using ansible module
Team, there are lvol module but I am having hard time find way to add new device to existing VG group. so I took alternate route to use shell module and running RAW commands. but is there a way I can ...