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
0 answers
16 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 ...
0 votes
1 answer
21 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: - ...
0 votes
0 answers
7 views

How to manage ports using proxycommand and ansible

Sometimes when I'm using ansible against a fairly large number of hosts (around 100) about 3-5 of them jump to a completely different host. These devices are all connected via proxycommand using ...
  • 1,416
0 votes
1 answer
22 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 ...
  • 1
0 votes
0 answers
25 views

ansible action plugin execute some modules once

I stumbled across following problem creating custom python ansbile action plugin: how to execute some modules once (i know in yaml it is possible to set run_once and delegate_to)? For example having ...
0 votes
0 answers
67 views

Unable to install Jenkins plugin via ansible

I've been trying to use ansible to install Jenkins and then once Jenkins has been installed, use the jenkins_plugin module to install the build-pipeline-plugin into it. Here's my code (also hosted on ...
  • 103
0 votes
1 answer
111 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 ...
  • 103
0 votes
1 answer
98 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 ...
  • 111
2 votes
1 answer
100 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 ...
  • 121
1 vote
1 answer
47 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 ...
  • 155
0 votes
0 answers
25 views

Ansible Tower / AWX - Job Execution when Instance Fails / becomes unavailable

I have queries on the Ansible Tower/ AWX job execution. While a playbook is under execution. Let's assume this is a lengthy list of tasks and below are the two scenario. This is more on towards ...
0 votes
1 answer
43 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 ...
  • 315
0 votes
1 answer
58 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 ...
  • 245
1 vote
1 answer
313 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 ...
  • 11
0 votes
0 answers
120 views

ansible win_copy cannot copy src file as it does not exist

I am trying to run a molecule test where it is supposed to create a VM and copy a binary from network UNC path to the VM but somehow it is failing with the below mentioned error. This is what the task ...
2 votes
1 answer
820 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 | ...
2 votes
1 answer
70 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"...
2 votes
1 answer
189 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 ...
0 votes
1 answer
38 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 ...
  • 1
1 vote
2 answers
128 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 ...
1 vote
4 answers
96 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 ...
1 vote
1 answer
170 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 ...
0 votes
1 answer
1k 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: &...
1 vote
0 answers
17 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 ...
  • 11
0 votes
1 answer
311 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&...
1 vote
1 answer
33 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/...
  • 223
0 votes
1 answer
346 views

Ansible / Jinja2 Unexpected templating type error

I am trying to take a dictionary from one or more async tasks "register: task_variable" then collecting it as a list based on its id's and running a wait task using async_status on the ...
0 votes
0 answers
343 views

AWX Ansible - Can't access repository Git and Bitbucket

I have configured and successfully used until some days ago a project in AWX, synchronizing it with a Bitbukcet repository. Now, when I am trying to sync the Project with the repository, I get this ...
  • 101
2 votes
1 answer
330 views

How to access elements of a variable in ansible

I'm trying to access a specific value in a list of data and it fails, can't find the ipa variable. Here is a short bit of the boulder.yaml vars file, yes, dual homed. Network configurations require it:...
0 votes
0 answers
41 views

What does `Networking` refer to in this diagram about Ansible?

I find a snapshot of ansible execute a Task. My questions about it: What's Networking in step 7, does it mean the network devices? EDIT-01 In this link we can also find the Networking: Networking – ...
1 vote
1 answer
173 views

How Can I Escape Backspace Using Set_Fact In Ansible With Jinja Conditional

I cannot figure out how to escape an HTML closing tag, <\b> in this example, when used inside an Ansible Jinja conditional (ansible 2.9.27 in this case). Using an additional backslash <\\b>...
0 votes
0 answers
25 views

What is the best approach for managing this local network of SBCs?

I am dealing with hundreds of SBC's (Raspberry Pi or similar). They are all networked to a central control PC via ethernet. I need to automate the following: Perform a network OS install Perform ...
  • 101
0 votes
1 answer
696 views

Ansible playbook fails on Windows server

--- # This is a basic playbook for testing - hosts: WindowsSandbox #gather_facts: no vars: ansible_remote_tmp: c\temp remote_tmp: c\temp tasks: - win_shell: cd c:\temp ...
  • 1
2 votes
1 answer
277 views

known_hosts module reports changed when nothing has changed

Why does my task report say that it has changed when nothing has changed? - hosts: localhost become: false gather_facts: false tasks: - name: Remove non existing host key from known_hosts ...
  • 121
0 votes
1 answer
898 views

How to run a task from a playbook to a specific host

I'm writing an ansible playbook to manage backup and I want two different tasks : - name: Setup local machine for backup cron: cron_file: /etc/cron.d/backup hour: 4 minute: 0 job: /...
  • 101
0 votes
0 answers
212 views

Where do modules in an Ansible Tower run come from?

I inherited an Ansible Tower installation where I do not know all the details. Given the following: Starting a Job from a template having a virtual environment /opt/virtualenv/venv-20220722/ This is ...
  • 101
0 votes
0 answers
106 views

How to use Ansible to create a Nexus npm repo

I need to use Ansible to create an npm repo in our Nexus server. I've been looking through the Nexus REST API documentation and figured that I would use the uri module to issue the relevant command(s) ...
  • 123
0 votes
0 answers
256 views

windows.win_shell not running as currently logged-in user

I am working on a playbook that is meant to upgrade software on a Windows machine. I would like to prompt any currently logged in users to cancel the upgrade if it is not a good time. I have the ...
2 votes
1 answer
78 views

Ansible: How to run ad-hoc command with multiple environnements?

Given the following architecture: ├── ansible.cfg ├── hosts │ ├── production │ └── staging ├── production │ ├── group_vars │ │ ├── all.yml │ │ ├── mygroup.yml │ │ └── mygroup2.yml │ ...
  • 63
0 votes
1 answer
128 views

How to keep packages updated and keep in pace with security updates

In a project with multiple vms that run various applications from Wordpress to Django and various other things. Is there a way or a tool to keep track of the packages that require updates or have ...
2 votes
1 answer
745 views

In Ansible, how do I assign a hostvar to a playbook's host?

The directory of my Ansible project has the following structure: project/ playbook.yml host_vars/ localhsot.yml roles/ ... terraform-provision/ ... terraform/ ... Here'...
1 vote
1 answer
176 views

Setup multiple Raspberry Pi different network configurations

For multiple projects we are setting up 2 to 6 RPi's per project. Each project runs on a different network and for some of these networks we can use DHCP, for others the RPi's have to connect using a ...
  • 113
3 votes
1 answer
1k views

How can I set let's encrypt certificates with Ansible?

I'm trying to get a let's encrypt certificate for my domain with Ansible. I have been reading this tutorial which is a bit outdated and the Ansible documentation. My playbook is a mix of what I have ...
  • 63
0 votes
0 answers
13 views

How to disable cross region replication for an instance in oracle cloud through ansible playbook?

I'm trying to disable cross region replication for an instance in Oracle cloud using ansible. So far I've come up with this: - name: Get information of all boot volume attachments in a compartment and ...
4 votes
2 answers
131 views

Why use configuration management tools in the world of modern cloud?

Configuration management tools like Ansible, Chef, Puppet, and Saltstack allows us to configure a cluster of blank machines to help install and deploy an application. For example, with Ansible, we can ...
1 vote
0 answers
30 views

Is there a good/best practice for temporary changes in Ansible?

Sometimes, I need temporary changes in a playbook. Like adding a firewall rule, do things, and remove the firewall rule again. Or adding a local package repository mirror, install packages from it, ...
0 votes
1 answer
694 views

Why can't my playbook find the community.docker modules

I am trying to write a playbook that will download a docker image and run it on a group of servers. I have a python 3.6 virtualenv created and installed ansible into it. I then ran: ansible-galaxy ...
  • 101
-1 votes
1 answer
160 views

ansible-doc command for filters & plugins

I would like to list & read documentation from the ansible-doc command for example about ipaddr or flatten. Is it possible? Thanks in advance!
  • 101
4 votes
1 answer
945 views

Ansible no user $HOME by default - so how do I run commands

I have thousands of servers that, by default, for security and space do not create a $HOME when you ssh in. This seems to be posing a problem for Ansible as it keeps trying to chdir to home that does ...
  • 141
2 votes
1 answer
51 views

Container deployment sync problem with Ansible

Imagine the following situation after you have switched from docker-compose to Ansible: You start a DB container which needs time to boot up You want to load data dump into it (could be also you ...
  • 6,762

1
2 3 4 5
9