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
14 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
25 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
0 votes
1 answer
22 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
  • 151
1 vote
1 answer
36 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
  • 151
0 votes
2 answers
55 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
43 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
  • 151
0 votes
1 answer
594 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
50 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
199 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
297 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
129 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
51 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
137 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
0 votes
1 answer
178 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
1 vote
1 answer
3k 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
  • 113
0 votes
0 answers
58 views

Is there an ansible command to configure a vmware host to synchronize time with the host?

I've been searching the docs for a bit, but is there a way in ansible - either the rest api or the built-in api - for vcenter to configure a host that has vmware tools installed to synchronize its ...
Peter Turner's user avatar
  • 1,440
0 votes
1 answer
4k 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
297 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
0 answers
103 views

Identifying worker nodes from Ansible inventory group which are not yet joined to k8s cluster using ansible.builtin.regex_search and regex_replace

I am using Ansible to configure a k8s cluster with several nodes. I have a playbook which checks if a variable representing the kubeadm join command has already been defined. If it has not, it ...
Jehan Alvani's user avatar
0 votes
1 answer
84 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
2k 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
100 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
606 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
570 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
68 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
449 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
200 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
746 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
259 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
475 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
2k 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
897 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
1k 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
784 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
495 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
77 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
  • 433
0 votes
1 answer
241 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
2k 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
11k 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
735 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
90 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
306 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
364 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
1 vote
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
0 votes
1 answer
10k views

Ansible jinja2 if/elif/else construct not working anymore

I am using a jinja2 template for creating several files. Those differ a bit dependent on a set variable. Here's the code: {% if production_env == "prod" or "stage" %} password: &...
diggnsaegg's user avatar
0 votes
0 answers
33 views

Implementing the right conditions for a yum command for centos5 in Ansible

I'm currently working with a centos5 host and I have to install some packages with yum. Unfortunately, as far as I know, centos5 doesn't support Ansible's yum module, since it requires python2 ...
Wander's user avatar
  • 9
0 votes
1 answer
2k views

ansible fatal: "sudo: a password is required", even after priveleges are escalated

while trying to setup a remote machine using ansible, I am running into the following issue: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n&...
vinylic's user avatar
1 vote
1 answer
82 views

Creating a hostgroup from a super-set of hosts

I have two host files with different hosts, hostGroups and super-set in each file like below. /ets/hostFiles/TestBoxes [TestBox:children] groupA groupB [groupA] ... ... [groupB] ... ... /ets/...
Siva's user avatar
  • 223

1
2 3 4 5
9