22,981 questions
-1
votes
0
answers
16
views
Bitbucket pipeline failed due to repo checkout permission issue - Ansible playbook steps involved
I am getting the below error when my Bitbucket pipeline fails. I am creating a new AWS AMI using the Packer tool. I am using an Ansible playbook to create a customized AMI. I modified permissions for ...
0
votes
2
answers
38
views
Identify if an environment variable is unset
I'm trying to write an ansible playbook to install my application. I'm trying to detect that an environment variable is unset. I know I can use the lookup plugin to find an environment variable like ...
0
votes
0
answers
7
views
how to update serial value in a playbook that depends on the number of hosts in a group
my playbook looks like
- hosts: web:back:front
serial: "{{ groups[group_names[0]] | length }}"
when i execute, it doesn't seem to work as the error points out that group_names variable is ...
0
votes
0
answers
27
views
Copy files looping with destination path based on source destination
I am using the following files/ organization for an Ansible project for src files to copy onto target (my roles all follow this scheme):
files/{{ ansible_distribution }}/etc/modules-load.d/i915.conf
...
0
votes
0
answers
23
views
Ansible get_url returning 400
When downloading a file with Ansible get_url from jfrog it always returns a 400. While trying this with curl works perfectly.
Ansible task with get_url that doesn't work:
- name: Download file
...
0
votes
1
answer
33
views
How can I use a jq query to extract a string from this Ansible dictionary?
So I have the following tasks in my playbook
- name: gather package facts
package_facts:
- name: send packages containing 'fence-agents' to a file
lineinfile:
path: /etc/leapp/transaction/...
0
votes
0
answers
30
views
Playbook using equals (=) instead of traditional flow collection syntax
I found a playbook that uses the following syntax:
- name: install apache2
apt: name=apache2 update_cache=yes state=latest
- name: enabled mod_rewrite
apache2_module: name=rewrite state=present
...
2
votes
2
answers
46
views
Use registered output fields as variables in ansible playbook
Please advise how to use registered data from one task as variables for another task in the same playbook.
Playbook:
---
- name: RouterOS test with API
hosts: localhost
vars:
hostname: "...
0
votes
0
answers
20
views
How to run integration tests in ansible over ssh
I'm trying to run simple hello world ansible integration test over ssh. How to authenticate ssh connection using username and password?
I've tried the following command
ansible-test integration --...
0
votes
0
answers
23
views
ansible with aws ssm, can not get s3 because proxy
i need to use a proxy for get a file from s3, when i try to connect to run an ansible code with ssm connection, ansible try to connect to my s3 bucket, but he can not it because he need a proxy, in ...
0
votes
0
answers
16
views
Ansible create vm playbook error ssl or ssl wrong version
Currently I have a playbook that will create vm by using ansible but encounter two different error depends on the pyvmomi that I used,
if I used pyvmomi(7.0.3) my ansible playbook will get an error
...
0
votes
1
answer
42
views
Using the lookup ansible.builitin.env on the environment variable PATH does not give the correct value
EDIT This might be a bash issue, so I asked a new question here https://superuser.com/questions/1864359/bash-no-such-file-or-directory-for-executable-in-path
My ansible role does the following:
...
1
vote
0
answers
43
views
Prevent & to & Translation in Ansible community.general.xml
I am using Ansible's community.general.xml to modify a file. I want to set the following
<Connector relaxedQueryChars="[]|{}^\`"<>"/>
The ...
0
votes
0
answers
22
views
How to fully remove a Windows EventLog, EventSource and corresponding entries to start over?
I face the following issue:
I created an EventLog and EventSource using this Ansible task:
- name: Add event log with source for auto-shutdown script
community.windows.win_eventlog:
name: "...
1
vote
3
answers
89
views
Ansible compare two JSON responses
I'm using Ansible to call the same administration API on two different servers and then selecting the core details of the applications from the responses using jq.
According to Ansible type_debug the ...
1
vote
2
answers
48
views
ansible , how to replace and filter json data?
I am trying to write ansible code first time to handle json.
I have a file in my /home/ which has following json data.
here is the input json
"acl": [
{
"browse": true,
...
0
votes
1
answer
48
views
How to read a value from JSON using Ansible?
Have the below Sample JSON:
{
"fulfilmentOrderItems": [
{
"customerDates": {
},
"instanceCharacteristics": [
{
&...
0
votes
0
answers
27
views
I'm facing a authentication problem with Gitlab Ci pipeline while deploying the Ansible playbook
I've added the public key in the remote node where the installation has to be done. The SSH private key value is added in gitlab as variable file, runner is setup, even though getting this error:
<...
0
votes
0
answers
21
views
How can I centralize a list of possible choices using Ansible roles argument_specs.yaml
Lets say that I have a role that uses meta/argument_specs.yaml, and I have a list of possible choices so that it can only be one of those values to be provided.
However I have more than one role that ...
0
votes
0
answers
30
views
Ansible custom folder structure
I have placed all the folders related Ansible inside AnsibleDeploymentScripts folder in a github repo. When I sync project in Ansible it is showing error like below. Is there any way to provide root ...
0
votes
1
answer
28
views
Extra_vars from rulebook appears undefined in the playbook triggered by run_job_template
The rulebook:
- name: Listen for events on a webhook
hosts: all
# Define our source for events
sources:
- ansible.eda.webhook:
host: 0.0.0.0
port: 5000
# Define the ...
1
vote
1
answer
67
views
Change ownership of parent directory chain recursively
I have a target linux node with default umask=0077.
When I run a playbook
- name: Create folder for app
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: ...
-1
votes
1
answer
36
views
ansible module to merge config files
Is it possible to merge(by auto resolving conflicts) 2 config files using Ansible?
For eg,
// c1.conf
A=20
B="Hello"
D=24
// c2.conf
X=30
A=20
B="Hello2"
C=31
E=33
//...
0
votes
1
answer
31
views
counting json objects in output in until
This is a follow-up to the following question:
Count number of json objects in output
I am writing a playbook that will patch our on-premise GitLab runners. The process I want is:
Pause VM's runner(...
-1
votes
0
answers
25
views
Calling Ansible Tower API using SpringBoot [closed]
I want to submit some jobs to Ansible using Ansible Tower APIs through Spring Boot. I am calling ansibleurl/job_templates to see the existing job templates and I am passing authorization token as:
...
-3
votes
0
answers
53
views
Trying to upgrade from Ruby 2.7.4 - 3.3.5 using Ansible & Packer
I'm new to Ansible and Ruby but I've been tasked with creating a new AWS AMI using Packer and Ansible.
I have updated the following application.yml from version 2.7.4 to 3.3.5 and the build fails.
...
1
vote
1
answer
38
views
Ansible environment lookup does not give content of variable but it is defined
I am trying to query the ORACLE_HOME environment variable, which is gathered via facts gathering.
I try to access it like follows:
- name: Print oracle_home env
debug:
msg: "{{ lookup('...
0
votes
0
answers
38
views
Retrieving the content of the file of remote host which is not part of ansible playbook command, how to achieve this
I am exploring the use of Ansible module called slurp in my playbook. Just curious to know if it works in this particular scenario here:
Situation: Joining a new rke2 agent node to the already running ...
2
votes
3
answers
108
views
ansible_python_interpreter_fallback is not working
I have a playbook with a mix of connection: local tasks and remote tasks that use an AWS dynamic inventory. The Python interpreter has different paths on local and remote systems.
Through another ...
0
votes
0
answers
33
views
Ansible data formatting and looping
I'm getting to grips with Ansible, I'm still pretty new to many basic concepts, so please bear with me.
My first target is to configure lists of interfaces on several devices. As input, I've got CSV ...
1
vote
1
answer
35
views
Check if an address is part of a list of subnets [closed]
In Ansible, is it possible to test if an IP address is part of a list of subnets?
I.e.: I have a list of subnets, ['10.10.10.0/24','10.10.12.0/24'], and an IP address: 10.10.12.8.
How would I test if ...
0
votes
0
answers
37
views
Ansible Playbooks: Missing required library
When executing a playbook with the ansible collection paloaltonetworks.panos I get the error message Missing required library
{“changed”: false, “msg”: “Missing required library
\\”pan-os-python\\“.”,...
0
votes
0
answers
27
views
Hashicorp packer version upgrade to latest 1.11.2 from 1.8.0
While upgrading packer version getting below error:
Error: Failed to initialize build "amazon-ebs" The builder amazon-ebs is unknown by Packer, and is likely part of a plugin that is not ...
1
vote
2
answers
39
views
Started a service in stopped state using Ansible
I'm trying to create an ansible playbook to start a service if it's only in stopped state. Created the below playbook.
tasks:
- name: Check the Service Status
ansible.builtin.command: ...
0
votes
0
answers
30
views
Ansible kubernetes.core.kubectl connection plugin : very slow - need advice
I'm trying to execute ansible playbooks inside a Kubernetes container.
The aim is to use Ansible Automation Platform to schedule ansible playbooks that are executed to configure our k8s clusters.
I ...
1
vote
1
answer
30
views
How to include encrypted file in Ansible jinja template?
I have 2 jinja templates containing private key:
private.key (encrypted)
private-copy.key (need to include content of private.key)
private.key file is encrypted using ansible vault, e.g.
ansible-...
-2
votes
0
answers
29
views
Passing credentials from Ansible Tower vault to YAML Jinja template
Ive currently setup login credentials on Ansible Tower vault for holocron access providing both:
Credential Type: Holocron 'AppRole' (RoleId & SecretId)
Anisble Vault saved creds
AppRole RoleId: ...
1
vote
1
answer
36
views
Ansible filters logic to process two dicts and add a new dict property based on key value
I have
- name: Replace group_ids with group_names in var_users
hosts: localhost
gather_facts: no
vars:
var_users:
- group_ids: ["e40c1163-269f-41f7-5555-57e1788a1999", "...
0
votes
0
answers
39
views
Is there a way in Ansible to lookup content in a host file without using another Ansible module/task?
Background: I had a lineinfile module that was using regexp and line to ensure I have correct lines inside of my config files. This works perfectly but there is an issue that I did not think of, other ...
0
votes
1
answer
40
views
Ansible - flatten keys/values muti-dimension dictionary
I have a multi-dimensional dictionary to configure where to grab images for multiple distributions.
- name: Test Playbook
hosts: localhost
gather_facts: false
vars:
distributions_images:
...
1
vote
1
answer
65
views
How to extract the values in ansible from the query_results of a SQL select?
I created a simple select to test the result of a MySQL installation in an ansible playbook:
- name: Simple select query to db playground
community.mysql.mysql_query:
login_db: {{ database ...
2
votes
0
answers
19
views
"Invalid JWT token - 'exp' claim expired" error from ansible-galaxy
I'm building an execution environment and it fails running ansible-galaxy collection install. I get this error:
ERROR! Error when getting collection version metadata for redhat.satellite_operations:3....
2
votes
1
answer
46
views
Ansible replace value with previous valid list value(s)
Hello community folks,
Let's imagine I have a list of strings that are either valid strings or spaces / non valid strings.
mylist:
-"First"
-" ...
2
votes
1
answer
80
views
Keep duplicate dictionaries of a list of dictionaries
In my playbook, I have a list of dictionaries. I want to keep only duplicate dictionaries.
Basically it is something like:
{
"l": [
{
"a": "d",
...
0
votes
1
answer
36
views
Ansible callback plugin prints metacharacters when playbook trace is redirected to file
I'm writing an Ansible playbook with an ad-hoc df -h command:
---
- name: execute df -h
hosts: all
gather_facts: false
tasks:
- name: Execute df -h
command: df -h
register: ...
0
votes
1
answer
26
views
Different inventories, same group name
I want to run an Ansible playbook with more inventories and I know it can be done by specifying before each inventory -i command. But I have in two different inventories a group with the same name, ...
0
votes
0
answers
33
views
Ansible: How to reset the ansible_python_interpreter variable in the middle of the playbook
In a data center environment (Hetzner), hosts can be network-booted into a so-called "rescue system" where the initial OS imaging and rescue operation can be done. The same host can then be ...
2
votes
1
answer
44
views
Ansible json_query move dictionary key/value to subkey that is a list
I'm trying to edit a dictionary in ansible with a one line json_query (and/or other filters), but something is wrong and I can't figure it out.
I have this structure (with example data)
seinfeld:
- ...
0
votes
1
answer
63
views
Ansible prompt for cisco-ios
I'm running ansible playbook that passes some aaa commands and everything runs fine until I hit this command:
aaa accounting identity default start-stop group ISE-RADIUS-SERVERS
That command triggers ...
1
vote
2
answers
50
views
How can I define changed_when based on file content?
I have a few installations on our servers and workstations, which are executed via proprietary setup scripts, for example MATLAB.
Do keep the idempotency I would like to analyze the log file, which is ...