Skip to main content

Questions tagged [ansible]

Use this tag for questions about Ansible, an open-source automation engine, related to using Ansible for topics such as cloud provisioning, configuration management, application deployment, etc.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

provided hosts list is empty, only localhost is available

I just started learning ansible, when I try to start ping, this error appears provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' [WARNING]:...
Аркадий Лоскутов's user avatar
1 vote
1 answer
28 views

Ansible Jinja2 evaluate string as template

I have a sort of configuration vars file through which I'm looping, checks: - name: "x" setting: "y" eval: "{{ 'OK' if var == 'x' else 'NOK' }}" main.yml - ...
Someboodyh's user avatar
1 vote
2 answers
27 views

How could I make ansible connection parameters dependent on the controller host?

There are various reasons where I would like to execute ansible on many different systems, in different configurations. Some example: Executing ansible on one of the hosts existing in the inventory, ...
peterh's user avatar
  • 202
0 votes
1 answer
35 views

how to force ansible to ignore $HOME/.ssh

When I verbosely launch ansible with ansible-playbook -vvvv -i inventory.yml directories.yml in middle of output I can see: debug3: hostkeys_foreach: reading file "/home/freq/.ssh/known_hosts&...
linux_beginner's user avatar
1 vote
1 answer
32 views

Ansible AWX issue - Ping module fails in my custom Execution Environment pod when running Jobs, but not when I start the Pod manually

I built a Docker image from CentOS 9 Stream via Ansible-Builder. When I spin up the Docker container I can ping VMs in my network. Also when I run a Playbook to manually create a K8s Pod from the ...
KidACrimson's user avatar
0 votes
1 answer
96 views

Enable MFA using google authenticator and Ansible

I have a Jump/Bastion server. want to enable MFA using goole authenticator. written an ansible playbook that install libpam-google-authenticator and modify the /etc/pam.d/sshd and /etc/ssh/sshd_config ...
Preetam's user avatar
0 votes
1 answer
104 views

How to ignore playbook failure when package missing in apt list?

I'm working on an Ansible playbook to install some specific Python versions to remote hosts from the deadsnakes repo. The remote machines are on a range of Ubuntu versions, so the Python versions ...
Mark Edwards's user avatar
1 vote
1 answer
182 views

Take shell cmd stdout_lines and create dict from output

I am using needrestart -b to get the following example output NEEDRESTART-VER: 3.6 NEEDRESTART-KCUR: 5.14.0-362.24.1.el9_3.0.1.x86_64 NEEDRESTART-KEXP: 5.14.0-362.24.1.el9_3.0.1.x86_64 NEEDRESTART-...
OldManWaterfall's user avatar
1 vote
1 answer
48 views

How to include a simple ansible vault file and refer its content from the whole ansible workspace?

I am thinking on a trival secret ansible vault: I have a secret.yml in my inventory, which is the single encrypted file in my ansible workspace, containing all the secret data. Its structure is very ...
peterh's user avatar
  • 202
1 vote
1 answer
88 views

How to manage lxd server configuration by ansible?

I am trying to set up the lxd global, server settings with ansible. Note, these are not the instance or container settings, these are the global settings of the lxd daemon. For example, core....
peterh's user avatar
  • 202
0 votes
2 answers
131 views

Run Ansible win_shell without double quotes

Below is my script win_shell: 'C:\\TEMP\\myscript.ps1 -password {{ password }}' But when it executes, it get executed as below and as there is a dollar ($) in password its not working properly. "...
Nice Thomas's user avatar
0 votes
1 answer
91 views

How to determine the color of a shell script task in Ansible?

There are various Ansible modules which can execute my own-written script (ansible.builtin.script, ansible.builtin.shell, ansible.builtin.command). However, I would like to determine the color of the ...
peterh's user avatar
  • 202
0 votes
1 answer
1k views

Ansible - 'loop' requires a list and got a list, but doesn't work

Minimal reproducible example: role/defaults/main.yaml: node_sysctl: kernel.shmall: 197951838 kernel.shmmax: 810810728448 kernel.shmmni: 4096 role/tasks/main.yaml: - name: Tune sysctl sysctl: ...
adoring_ellis's user avatar
0 votes
1 answer
170 views

How to design an ansible workflow over multiple hosts?

I am new to ansible and I am wondering how I should design my workflow with ansible in an ansible kind of way. The Task: I have a workflow/process (not ansible yet) for setting an application up. ...
Mike's user avatar
  • 1
1 vote
1 answer
592 views

How to pass the result from one task (on one host) to another task (on another host) inside an ansible playbook?

I can't get this seemingly easy play to work: --- - name: Get the filename hosts: host1 tasks: - command: # find command that returns a filename register: filename - name: Use the ...
Tim's user avatar
  • 113
1 vote
1 answer
451 views

How can I put some set of machines to a group in an ansible inventory dynamically using the add_host ansible module?

I am trying to dynamically populate an inventory group called cloned_group in my current inventory . I passed the hostnames through the survey by the following names clone_machine_1, clone_machine_2, ...
Kavisha Abeynayaka's user avatar
0 votes
1 answer
153 views

Conflicts while building AWX-EE custom image

I'm currently building AWX EE custom image with the latest available but it seems latest versions got some conflicts with pip modules. My custom image was working great in July (awx-ee version 22.X 23....
motorbass's user avatar
  • 113
2 votes
1 answer
67 views

Creating a cmd task with all the private ip address details collected from gather_facts

I am running an Ansible playbook from my local laptop to AWS connecting on the public IP address. The infra is being spun up by terraform so I don't know the private IP address before hand. I have ...
ranjit abraham's user avatar
1 vote
1 answer
164 views

Ansible inventory for restart on worker node

I looking to execute a simple reboot via Ansible using its playbook - name: Worker-node Reboot hosts: node1 gather_facts: no remote_user: team become: true tasks: - name: Reboot the ...
Terra's user avatar
  • 13
1 vote
1 answer
261 views

Trying to Create a Docker Ansible lab and Cant SSH

I'm trying to setup a mini ansible lab with docker containers. I have 1 Rockylinux based container as the ansible controller, and then (for right now) 1 Rockylinux based container as the host. For ...
egkennedy93's user avatar
2 votes
1 answer
4k views

How to reload the Firewalld service using Ansible?

I have added some rules to firewalld on CentOS via Ansible. But I need to reload the firewalld daemon for the service to work properly and permanently. Is there a way to do this in Ansible? Here is my ...
Ali's user avatar
  • 123
0 votes
1 answer
5k views

Is there a way to declare global(?) variables inside an ansible task?

I have an Ansible playbook, this playbook has a role on it, this role is configured to run only on 2 hosts: yaml - hosts: node1,orchestrator1 gather_facts: True any_errors_fatal: True ...
k.Cyborg's user avatar
  • 175
0 votes
1 answer
330 views

Ansible Connecting to remote Docker container over SSH

I have the following situation: I have a remote server that runs docker with a Postgres container. The Postgres instance is only reachable through a docker network, not directly from the remote server....
Tiim's user avatar
  • 11
0 votes
1 answer
111 views

How can I log every command for which an Ansible playbook uses elevated permissions?

I have an Ansible playbook that runs against a Linux target host and uses become to gain elevated permissions for those actions that require it. For auditing purposes, I need a list of all the Unix ...
jstarek's user avatar
  • 123
0 votes
1 answer
3k views

how to run powershell script as windows administrator user using ansible

i want to run a power shell script on remote windows machine. The PowerShell script will install software on C drive. The user which used to login is already in administrator group. But when the ...
heyloitsmeraj's user avatar
1 vote
1 answer
138 views

Why doesn't ansible.builtin.lineinfile behave as expected in this particular task?

I'm attempting to update /boot/firmware/cmdline.txt on a few Raspberry Pis to enable cgroup support. Seemed a good fit for ansible.builtin.lineinfile. The existing contents of /boot/firmware/cmdline....
Jehan Alvani's user avatar
0 votes
2 answers
691 views

why does my Ansible playbook throw "Found existing installation: requests 2.25.1\n\n:stderr:ERROR: Cannot uninstall requests 2.25.1"?

I'm trying to run an ansible playbook that installs docker and docker-compose and runs a compose file on a ec2 t2.micro. To use the docker modules in ansible, I need to have docker and docker-compose ...
Keshav Singh N's user avatar
0 votes
1 answer
823 views

Unable to create a project with MANUAL as source in AWX

I have followed the instructions to install AWX from this site. https://computingforgeeks.com/install-and-configure-ansible-awx-on-centos/ But I'm unable to create manual SCM project on new project on ...
Siva's user avatar
  • 223
1 vote
1 answer
103 views

ansible_become has no effect despite the ability to execute sudo on GCP hosts

Say I want to execute the following command on target hosts (deployed on GCP): ansible all -a "head -1 /etc/shadow". The command demands the root access. With the default Ansible ...
SkogensKonung's user avatar
0 votes
2 answers
574 views

Run dependencies only once in muliple plays in Ansible

I have a collection of roles that all depend on a common role: # roleA/meta/main.yaml dependencies: - role: common # roleB/meta/main.yaml dependencies: - role: common # roleC/meta/main.yaml ...
FuriousGeorge's user avatar
2 votes
2 answers
229 views

Use an asymmetric cypher to secure Ansible vault

I'm trying to develop a Playbook which must handle sensitive user data (SSH keys, Registry credentials, etc.). Only a user and the Ansible controller can see the data associated with that same user. ...
Adrien H's user avatar
  • 121
1 vote
1 answer
890 views

Ansible role depend on other roles

I have a role, foo that installs a file {{ foo_path }} that's defined in roles/defaults/main.yml. I have a second role, bar that depends on that file being there. I could put foo in the roles/meta/...
FuriousGeorge's user avatar
1 vote
1 answer
320 views

Use ansible to create GitHub repository with README

We use Ansible to automatically setup Kubernetes clusters. KPT https://kpt.dev/ is further used to deploy config files to pods in these clusters. In this process we need to create new GitHub ...
r3volutionxxx's user avatar
1 vote
1 answer
633 views

Using a different Python version in AWX

I updated a recent playbook module that says I need to use at least Python version 3.8. I run this playbook on our AWX controller. When I run the cmd module and do a "which python3" I get ...
David Desjardins's user avatar
1 vote
1 answer
3k views

Why is Ansible task getting stuck for so long?

I'm new to Ansible, I've made a playbook with only two tasks as shown below: - name: Installing Kubernetes for the master node connection: ssh hosts: x.x.x.x become_method: su tasks: - ...
Muhammed Adil's user avatar
0 votes
1 answer
1k views

How to define rollback or rescue in ansible folder structure?

I would like to define rescue or rollback executions within my Ansible structure. I am using this recommended structure: roles rolename files tasks templates handlers ... I know ...
Vietna's user avatar
  • 25
0 votes
1 answer
1k views

Multiple shell commands not executing with shell module

For some reason this fails: - name: "Get GPG key from the Jenkins portal" get_url: url: https://pkg.jenkins.io/debian-stable/jenkins.io.key dest: /usr/share/keyrings/jenkins.io.key ...
Skegg's user avatar
  • 103
0 votes
1 answer
2k views

How to Control Ansible Loop or Task Default Output

I am trying to get my playbook to print readable debug output for stat on a number of directories when executing. The below shows the with_items and loop way and both work but the real problem is the ...
chipfall's user avatar
  • 111
2 votes
1 answer
883 views

Should I turn off copilot for text files containing secrets?

I use VSCode and have recently started using GitHub Copilot for my projects (programming and devops related). I understand that Copilot will send parts of my text to a remote server to get suggestions ...
cherouvim's user avatar
  • 141
1 vote
1 answer
641 views

Why is ansible loop adding square brackets ("[]") into my role?

I'm writing a role where I need to iterate over a list using the loop option. I'm using the ZFS module aisbergg.zfs. The role: - hosts: localhost vars: zfs_pool_name: tank ...
k.Cyborg's user avatar
  • 175
0 votes
1 answer
85 views

Where does Ansible DSL get translated to either Powershell or Python?

When running Ansible scripts, where does the translation from Ansible DSL to Python(Linux) or Powershell(Windows) happen? I assume this is on the Ansible node, that is, where the Ansible command is ...
Chris F's user avatar
  • 463
0 votes
1 answer
285 views

How to verify the time zone change is correct on AWS EC2 using Ansible?

We can use the following code to set a new timezone on AWS EC2 using Ansible. --- - hosts: linuxservers proxmoxservers remote_user: ansible become: yes tasks: - name: 'Set timezone to Buenos ...
Biju's user avatar
  • 255
1 vote
1 answer
3k views

Ansible Unsupported Parameters for using handler

I'm trying to run a ansible task but I keep getting an error. This is the play I want to run: - name: use of handlers hosts: all tasks: - name: install packages yum: name: httpd ...
Sandy's user avatar
  • 11
4 votes
1 answer
14k views

Ansible: How to get hostname without domain name?

How to get value from /etc/hostname ignoring domain name. For example, /etc/hostname says "client.test.dom" and I need to get "client". I have tried "{{ ansible_nodename | ...
Виктор Гринько's user avatar
2 votes
1 answer
922 views

How to lock a user using ansible?

Given a username, if that user exists, lock it, otherwise keep it missing. The most likely module is ansible.builtin.user. There passing password: "*" and shell: "/usr/sbin/nologin"...
Helmut Grohne's user avatar
2 votes
1 answer
2k views

How to create, but not overwrite, a file and manage its permissions with ansible?

The task seems simple. If the file does not exist, create it, otherwise retain the file and its content. In both cases, apply permissions (owner, group, mode). The most obvious candidate to this task ...
Helmut Grohne's user avatar
1 vote
1 answer
101 views

Unable to login as `ubuntu` user on ec2 instance spawned from auto scaling group

Utilizing Ansible AWS modules, I'm creating an AMI from an existing EC2 instance where I am able to ssh with both my user and default account (ubuntu). After the AMI is in a ready state, I then create ...
Chris's user avatar
  • 11
1 vote
2 answers
350 views

Is there a way to exclusively manage multiple ssh keys with differing per-key options using ansible?

Ansible provides a ansible.builtin.authorized_key module which provides a lot of functionality: You can set exclusive: true to delete all other keys. You can set key_options: .... You can list ...
Helmut Grohne's user avatar
1 vote
4 answers
406 views

What is a good strategy to prevent Ansible playbook runs against the wrong hosts? [duplicate]

It is too easy to run playbooks on the wrong hosts in Ansible I know the best practice would be to use --limit to make sure you can not select the wrong host. I do not trust --limit to ensure Ansible ...
timfox123's user avatar
3 votes
2 answers
1k views

Ansible - Configuring Supermicro servers via Redfish API

I plan to configure Supermicro servers via the Redfish API. Ansible provides the following modules for the Redfish API: community.general.redfish_command community.general.redfish_config Supermicro ...
stackprotector's user avatar

1
2 3 4 5
9