Questions tagged [ansible]

Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

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 ...
user avatar
-1 votes
0 answers
16 views

jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection

I am stuck to configure publish over ssh on Jenkins, Jenkins container to ansible container in CLI. I am able to do SSH via Private key, but the same private key when I am using publish over ssh in ...
user avatar
0 votes
1 answer
18 views

Ansible - nginx package removed, but service is running on the server

I'm trying to learn Ansible, but I have strange thing. I have below playbook: --- - name: "Uninstall apache server" hosts: all become: true tasks: - name: "Uninstall packages&...
user avatar
  • 119
2 votes
1 answer
34 views

linenfile Ansible module doesn't insert all lines as expected

I am trying to print a few lines to a file of each target host. However, the lines are missing from the file. This means, my hostlist file has about 10 servers. I get lines only for 8 sometimes or 6 ...
user avatar
0 votes
1 answer
27 views

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 ...
user avatar
  • 642
0 votes
0 answers
34 views

AWX/Ansible Tower - unable to resolve Module Dependency - "No module named 'azure.cli.core.auth' "

I'm trying to install the Azure.Azcollection module on an AWX server, but encountering the following dependency error: TASK [List all keys in specific key vault] ************************************* ...
user avatar
1 vote
0 answers
22 views

Register Oracle Linux to Satellite 6

OEL is an RPM based downstream project from RHEL; however, if you use ULN, subscription-manager an other pieces are missing, and cannot be loaded from OEL repositories. How do you register OEL to ...
user avatar
0 votes
0 answers
27 views

How to properly define ip6tables rule in ansible

On current system I have this rule for ip6tables -A INPUT -d <ip6address> -p udp -m udp --dport <port> -m state --state NEW -j ACCEPT For new system I wrote an ansible playbook: - name: ...
user avatar
2 votes
1 answer
52 views

Ansible dual log format

On Ansible config I can set if output log should be human-readable or JSON. Human readable format is displayed task-by-task as it runs and JSON only after playing ends. It is possible to output to ...
user avatar
  • 31
0 votes
1 answer
51 views

Ansible: Loop over template with related variables

Given the variable structure syncjobs: - filename: output1.bash content: data1 - filename: output2.bash content: data2 I want to loop over it creating the files with ansible.builtin....
user avatar
0 votes
0 answers
12 views

How can I (re)create a LXC image with ansible?

I have a server with custom made LXC images. My users can create containers from thoses images. Until now, when I needed to change some configuration to the image, I went into a tedious workflow of ...
user avatar
0 votes
0 answers
32 views

User not found in /etc/passwd error while installing kubernetes cluster with kubespray

I am trying to deploy a Kubernetes cluster using kubespray, however, when I run the command: ansible-playbook -i inventory/mycluster/hosts.ini --become --become-user=root cluster.yml It displays the ...
user avatar
3 votes
1 answer
157 views

Ansible -- The offending line appears to be:

I'm trying to implement a playbook to grab the external IP address at a few locations but it keeps giving me this same error: The offending line appears to be: remote_user: pi tasks: ^ ...
user avatar
1 vote
1 answer
26 views

How to prevent being cut off a remote machine after a misconfiguration of a firewall playbook

Despite being careful, such a situation can happen and can be very toilsome to fix.
user avatar
  • 451
0 votes
1 answer
52 views

How to enable and restart a systemd service after changes to their configuration

Given a set of previous task whose results I register, I want to: Enable my target service. Restart/reload it when any of the dependencies have changed.
user avatar
  • 451
1 vote
1 answer
71 views

Ansible Ad-Hoc command - raw module not working on Cisco IOS devices

trying to use Ad Hoc commands on both my Cisco ios Router and Switch with the -m raw Module. But getting the following error instead. $ansible -i inventory_file02.ini netgrp -m raw -a "show ...
user avatar
  • 11
2 votes
1 answer
96 views

json_query help - not producing expected output

I am trying to build an array to use for with_nested, but I cannot get past why json_query isn't outputting the actual hosts assigned to each cluster: Play: - name: Index clusters.json shell: cat {{ ...
user avatar
0 votes
1 answer
66 views

Ansible regex_search module

Can anyone please help me to explain this code in ansible regex_search module: - set_fact: regex: "{{ '/opt/conf/path.txt' | regex_search('/?(.*)', '\\1') }}' What "\\1" means in ...
user avatar
1 vote
1 answer
43 views

Best way to reformat a JSON with Ansible?

I have this JSON in a variable : { "device_vlans": { "1": { "name": "default", "interfaces": [ "GigabitEthernet1/...
user avatar
  • 61
0 votes
1 answer
21 views

Load vars based on env in ansible

Team, I have two vars that map to two environments. I want to use them in playbook but only one value should be applied based on env playbook runs on. ex: var = test1 > should be loaded when env1 ...
user avatar
  • 109
0 votes
1 answer
55 views

Ansible Parted, only run if no partitions exist

I want to only run the parted operation if no partitions currently exist on that device. Said parts could have been made previously or manually outside of ansible in the past and in that case should ...
user avatar
  • 3
0 votes
2 answers
53 views

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 ...
user avatar
0 votes
0 answers
83 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-...
user avatar
  • 327
1 vote
1 answer
63 views

How to validate variables contents in Ansible?

ansible-lint only checks the tasks/handlers and doesn't iterate over the variables (e.g. if you're using with_items, it won't iterate over all the items) and yamllint only checks cosmetic issues and ...
user avatar
1 vote
1 answer
68 views

Ansible task for updating/cleaning up dbatools failing

I keep the Installation of the dbatools.io PowerShell module updated on my MSSQL Servers with a simple Ansible playbook which includes the following task: #################### UPDATE DBATOOLS #########...
user avatar
  • 149
0 votes
1 answer
27 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 ...
user avatar
0 votes
1 answer
29 views

How to check a single rule with ansible-lint?

How do I check just the yaml: truthy value should be one of [false, true] (truthy) and nothing else?
user avatar
0 votes
0 answers
40 views

How to list the different java versions installed in a Linux server using Ansible ? How to switch from one version to another using ansible?

I want to know whether two different Java versions are installed in a Linux machine. In my case I want to see whether Java 8 and Java 17 is installed in the machine first, and if the Java 8 is the ...
user avatar
0 votes
1 answer
828 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 --- - ...
user avatar
0 votes
0 answers
73 views

AWX/Ansible Tower unable to see playbooks in tasks role subdirectory?

I'm adding some of my Ansible playbooks into AWX/Ansible Tower, using Azure DevOps as a back end git repo, but I've found after converting them into a more role based structure that certain playbooks ...
user avatar
0 votes
0 answers
100 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 ...
user avatar
3 votes
5 answers
1k views

Ansible OpenSSL Error with apt module

This is rather odd, I noticed it yesterday on one of my target machines, and today its happening on the rest of them too. I also tried running the playbook from a different machine and the same thing ...
user avatar
  • 133
0 votes
1 answer
68 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 ...
user avatar
  • 65
0 votes
1 answer
259 views

Ansible "hip-profiles unexpected here" Palo alto panos_security_rule

I'm trying to set a security policy on my Palo Alto firewalls using Ansible with the panos_security_rule module. However, I keep running in to the same error, hip-profiles unexpected here. I found ...
user avatar
  • 65
1 vote
2 answers
42 views

what ansible filter can I use on hostvars to extract string

"{{ hostvars['DUMMY_HOST']['iosengineID'] }}" value returns is this {'msg': [['80000009045B575A5032333331303055565D']], 'failed': False, 'changed': False} Which filter can I use extract ...
user avatar
  • 11
0 votes
0 answers
117 views

AWS Peering connection with ansible: "No route to host"

I have an EC2 instance in us-east-1 which would like to communicate with another instance in us-west-2. VPC-East CIDR: 172.16.0.0/16 VPC-West CIDR: 172.17.0.0/16 The used subnets in these VPCs are 172....
user avatar
  • 101
0 votes
0 answers
50 views

How to assign a static IP with molecule-podman?

As the generated inventory look like a pair of instance name - ip (see above), I need to test recipe using the variable ansible_host with an IP value and not the instance name. So the generated ...
user avatar
0 votes
0 answers
38 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 ...
user avatar
0 votes
2 answers
170 views

Ansible says Invalid options for debug: ansible.builtin.debug

I've been quite busy building a script. At some point I need to generate a password and store it in a file. The password is generated with - name: Generate new password debug: ansible....
user avatar
0 votes
2 answers
47 views

Ansible with_items not looping

I think I've been at this too long, but I cannot for the life of figure out why my second with_items is not looping like my first. I already tried using a json_query like in the first task, which did ...
user avatar
0 votes
0 answers
163 views

Failing execute yum from ansible on centos 8

I have a problem updating Centos 8 systems due to repositories. This is my task and it works on Red Hat and Almalinux: - name: Install the latest version of yum-utils become: yes become_method: ...
user avatar
0 votes
1 answer
78 views

How to register Ansible actions in Windows Event Log?

Ansible: 2.9 Windows: W2k16 Server I'm searching for a method to register (log) Ansible actions in remote Windows host. For example, when I work with win_command module for echo test command, I can't ...
user avatar
  • 13
1 vote
1 answer
276 views

ansible - get list of all hostnames and corresponding ansible_host values from inventory

My inventory looks like this: db0 ansible_host=10.0.0.1 db1 ansible_host=10.0.0.2 app0 ansible_host=10.0.0.3 app1 ansible_host=10.0.0.4 ... From this, I need to extract a list like this: - name: db0 ...
user avatar
  • 4,092
0 votes
0 answers
68 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:...
user avatar
  • 835
1 vote
1 answer
90 views

Ansible condition to filter within loop

I am trying to create an Ansible task to remove RDM disks from a VM when the scsi_controller value is not zero. However, the when condition is skipping the entire task rather than walking the loop and ...
user avatar
1 vote
1 answer
48 views

Reduce ansible task boilerplate with some kind of template?

I'm looking for ways to reduce the amount of boiler plate config I have to put into some of my ansible tasks. For instance I have many tasks using the docker_container module, and each one has the ...
user avatar
  • 5,937
0 votes
0 answers
44 views

Ansible simple inventory for dhcp hosts in yaml

Need a little hint on yaml syntax for a very simple inventory file. I want to include dhcp range of workstations in a nice inventory file. Regarding the official documentation this could be done but i'...
user avatar
0 votes
1 answer
40 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/...
user avatar
  • 1
0 votes
1 answer
242 views

How to register a variable in one role and use it in another one in Ansible?

I am trying to register a variable in a role and then use it in another one. Here are the different files I'm using : playbook.yml --- - hosts: hostsgroup1 [...] roles: - role1 - hosts: 127.0....
user avatar
2 votes
2 answers
241 views

How to add ssh keys via Ansible when AuthorizedKeysFile is set?

How can I get Ansible to populate the correct file when my /etc/ssh/sshd_config has AuthorizedKeysFile set to /etc/ssh/authorized_keys/%u? Ansible seems to ignore the setting and places keys in $HOME/....
user avatar
  • 171

1
2 3 4 5
33