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.

0
votes
1answer
14 views

Task to delete users without mount points in /home (using register and when)

I have a list of users that I want to delete (del_users), but I only want to delete those that haven't mountpoint on your /home directory. My currently code is: - name: Verify if exist mount point on ...
0
votes
1answer
29 views

Ansible equivalent of below sed command

How can i use ansible lineinfile module to simulate working of below sed command. sed -i _bkp '/(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.1)(PORT = 1501))/d;s/(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0....
1
vote
1answer
14 views

How to downgrade Jinja for Ansible?

I'm using Ansible 2.8.0 (ansible --version installed by brew on macOS) which is using Jinja 2.10. I've tried to downgrade Jinja to 2.8 via pip3 install jinja2==2.8, and I can confirm the right ...
2
votes
0answers
26 views

Is there any way of getting code coverage with molecule?

I'm currently working on testing Ansible roles with Molecule. I have one role with 2 scenarios that are executed in Jenkins but just before that, those are submitted to a SonarQube analysis. So I ...
0
votes
2answers
42 views

run ansible command as another user using their ssh key

i am trying to figure out how to run an ansible ping command as another user, using their ssh key. User setup i have essentially: master_user (me) ansible (sudo user, pwdless sign in) I logged in ...
0
votes
1answer
70 views

Ansible - stop when host is success, exit with IP

Basically, my use case is that I want to run on list of hosts (group from inventory). It will run one by one, until it finds machine answer my standards, when it find the one with free RAM as I say e....
0
votes
0answers
17 views

Ansible, use restrictive file perms if vault secrets in file

TLDR; Is it possibly to determine from within a playbook or role whether a file or template contains a string found in a vaulted configuration file in order to protect secrets? I am recursively ...
2
votes
1answer
50 views

Ansible to check version of software on remote hosts before install/upgrade

Goal: Skip the host if version of custom software (non-rpm based) installed at remote host is greater than or equal to software version intended for upgrade. For all intents and purposes, this ...
0
votes
0answers
20 views

redirect all of commands output in a file on ansible server

I have my ansible server and 3 other servers with database on them that i defined in my inventory/hosts: [database] host1 host2 host3 and i have this task that get HADR role from each server: ...
0
votes
0answers
27 views

Can not run Ansible command with another user

I have this in my yml: --- - hosts: standby sudo: true sudo_user: test roles: - zab When I want to run an ansible command like /usr/bin/ansible-playbook -i /path zab.yml --tags ...
2
votes
1answer
35 views

Preventing accidental production deployments

Last night I ran a playbook from a wrong branch that referenced an old inventory file with old IPs for each server, and deployed a dev build to a production machine. What would be a a good practice to ...
0
votes
1answer
23 views

Ansible playbook fails with: no test named 'success'

I have an Ansible Playbook that is used to configure WSL on my Windows Laptop, having rebuilt my laptop recently I needed to run the playbook again, however it is failing with the following message: ...
0
votes
1answer
18 views

how to give a user privilege to run Ansible commands or just an specific tag?

for example, I have a tag named 'installagent' and i want to run this command ansible -playbook -i /path agent.yml --tags installagent from another server via ssh on my Ansible server with user '...
0
votes
1answer
23 views

how to run an Ansible command for specific number of hosts

I am new to Ansible and i have a question about limitting hosts in a host group at running commands.I have these host groups in my inventory: [primary] host1 host2 [standby] host3 host4 ...
1
vote
1answer
17 views

How do I get the hosts from a specific section of an Ansible `hosts` file in a Jinja2 Template

I have a hosts file including the following contents [elasticsearch_nodes] host1 os=linux host2 os=linux host3 os=linux In a .j2 template I want to get the the list of [elasticsearch_nodes] {{ ...
3
votes
1answer
32 views

Configuration Management Tools and Rollbacks / Approaching Immutable Infrastructure

I am interested in whether there are any configuration management tools out there that make it easy to roll back. So far it seems that with Ansible, Chef, and Puppet you have to write the roll back ...
2
votes
1answer
136 views

passing args to shell module in Ansible adhoc command

Is it possible to pass args, to the shell module when running it as an adhoc command? I can pass the free_form parameter using -a, but I am trying to figure out how to specify additional arguments, ...
2
votes
1answer
75 views

Unable to run playbooks using Ansible best practices layout

I am very new to ansible and I think I am lacking something basic that I am not finding in the examples or on github as to the directory structure and its use. I have set up my directory structure ...
0
votes
2answers
28 views

Get Ansible to print lines for include_role(s)

I figured this would be trivial, but can't find the answer anywhere. Let's say I have a playbook.yml that looks like: - hosts: all tasks: - name: I'm a block! block: - name: I'm a role! ...
0
votes
1answer
28 views

ansible does not play roles and tasks

I'm learning ansible and I'm having a problem, when I run my playbook, it only runs the gather_fact task and does not play my roles. On the other hand when I run just a module with the ansible ...
0
votes
1answer
16 views

Ansible: Copying different files to different guests for use with the same role

I have a role, let's call it apache2. The role installs apache2 and all of its dependencies. Now I have two machines, let's call them M1 and M2. Both M1 and M2 need to have apache2 installed. However,...
1
vote
2answers
38 views

Ansible authorized copy from remote source to remote destination

How to use ansible authorized_key to authorize a ServerA (not the controller machine) to access Server B. Scenario: Need a playbook to execute from a ansible controller that should append id_rsa.pub ...
3
votes
1answer
54 views

Override Ansible task parameters from role

I'd like to be able to define a task with default parameters: - name: Create a new user user: name: "default" password: "password" state: present Then, from my playbook, I'd like to be ...
1
vote
2answers
31 views

Getting rid of redundant Ansible roles

I currently have a bunch of roles, like: apache2 gcc gedit ...etc. For each of those, I have a task file that looks like this: --- - name: "Install {{ role_name }}" become: true package: ...
2
votes
1answer
69 views

Structuring Ansible playbooks for low volume, purpose-built images

I hope this question is not too vague / opinion-based: I need to create and maintain a handful of virtual machines that get packaged up and deployed out to thousands of users, depending on specific ...
0
votes
1answer
107 views

Ansible cloudformation vs cloudformation

I would like to know the difference between - AWS cloudformation - Make AWS cloudformation template through Ansible (https://docs.ansible.com/ansible/latest/modules/cloudformation_module.html) I ...
0
votes
1answer
30 views

unable to save register value even if the play is skipped!

I have situation where i fetch some ip address on the fly with this play, when env variable is passed as prod, i have to fetch ip in a diff way then when i am in QA env. If env is prod the 1st play ...
0
votes
1answer
39 views

Looping through found files in Ansible

I am trying to set the sendmail_path to use Mailhog in all php.ini files on a server with multiple versions of PHP installed for PHP FPM. Why is the following snippet is not working? - hosts: ...
0
votes
1answer
62 views

Looking for Ansible equivalent method to yml Anchors, Aliases, when using include file

Using Ansible with the aci_rest module, requires the authentication parameters (hostname, username, password, method, validate_certs) to be defined in every task e.g. aci_rest: hostname: "{{ ...
0
votes
1answer
52 views

How can I check for an installed packaged version on multiple linux hosts?

i need to check more than 100 servers for the snapd package, but I don't like the output at all. I searched all day for different options without luck. Attached is the output of ansible-playbook. Any ...
3
votes
1answer
96 views

How to have Ansible move a microservice?

I am working with a microservices application that is using Ansible to deploy to a fleet of VMs. We have different numbers of replicas of each microservice type running across the VM fleet. ...
0
votes
1answer
50 views

How to add LDAP group for ssh access by ansible playbook?

I have LDAP Group. superproduct1 In LDAP Group has some users: developer1, tester1, analitic1, project1 I want to create ansible playbook for add LDAP group to SSH access on host. Found only ...
1
vote
1answer
35 views

Chef vs Ansible: will configuration be applied if connection is lost during configuration pulling/pushing?

Scenario Configuration management tools like Ansible or Chef often have a master/controlling machine and the machines they are controlling (agents). Question What if the connection between master ...
0
votes
1answer
104 views

ansible aws windows ec2 - Internal Error: this connection module does not support running commands via sudo

I am getting below error when I am trying to run one playbook which connects to Windows machine hosted on AWS EC2. I enabled winrm and win_ping worked fine but when I am invoking ansible-playbook I am ...
1
vote
1answer
37 views

How can I issue a Let's Encrypt certificate with Ansible when 'challenge_data' cannot be found?

I am attempting to use the Ansible acme_certificate module to acquire a Let's Encrypt TLS certificate. I have successfully generated the private keys, CSRs, etc, and then started the challenge using ...
5
votes
2answers
86 views

How can I eliminate the need for an Ansible control machine?

Ansible is great for deploying infrastructure, but it requires you to have a control machine. This adds the burden of manually setting it up and securing it, and then pulling down your playbooks and ...
1
vote
3answers
237 views

Can Ansible use a local repository?

I have multiple hosts and my playbook has apt, pip modules to download necessary packages from repositories. When any (apt,pip) download module attempt to download packages, it does it for each host ...
1
vote
1answer
26 views

Can I check whether ansible is on last batch of rolling update (serial: 25%)?

I'm using Ansible to update a pool of EC2 servers with a rolling update, in batches of 25%. In between batches, I'm pausing long enough for the server health checks to start to pass again (since they'...
0
votes
0answers
39 views

Need help with massaging data from ansible modules

I have retrieved data from Azure using the azure_rm_*_facts modules, and have ended up with some data (after tweaking) like this: { 'nics': [ { 'fw01port01': { 'ip': '10....
2
votes
2answers
75 views

Ansible How to use plugin parameter

In Ansible, I want to use a plugin parameter. For example, the profile_tasks plugin supports a parameter to "Adjust the sorting output of summary tasks". I enable this plugin by whitelisting it in ...
3
votes
1answer
563 views

Ansible how to know what return value is provided by a specific module

From Ansible's official doc Ansible modules normally return a data structure that can be registered into a variable, or seen directly when output by the ansible program and Ansible modules ...
0
votes
1answer
72 views

Trying to execute an appcmd command via Ansible [closed]

I trying to execute the below command and running into errors ... I tried with quoting around the arguments, that didn't help either - name: Add authorization rules to FTP site win_command: ...
3
votes
1answer
92 views

Configuring Zookeeper from Ansible

I'm trying to configure a Zookeeper Cluster with Ansible. As you might know Zookeeper has two important config files. zookeeper/conf/zoo.cfg I create this file on each cluster member using this ...
7
votes
2answers
739 views

How to solve “E405: Remote package tasks should have a retry” in Ansible?

E405 v4.0.0 Remote package tasks should have a retry Package operations are unreliable as they require network communication and the availability of remote servers. To mitigate the potential ...
5
votes
3answers
112 views

What are tools that lend themselves for backup and recovery in a CI/CD environment?

I have used tar, dump, Amanda, Legato (EMC) Networker and other backup software for making backups of systems. However, I don't know the best tools for making backups in a CI/CD (Continuous ...
3
votes
2answers
118 views

Is there a system which automates everything (OS release, and above) to host websites on?

This is not really a DevOps question but more of a System Automation question (which DevOps covers only a part of, by popular opinion, so I hope it's okay). I feel like some 5 USD IaaS VPS with ...
0
votes
2answers
102 views

Should local Ansible playbooks be loaded each day/week with cron?

I ssh into a remote 5$ debian:stable IaaS machine with Putty. The machine has only debian:stable and Ansible installed on it and I run an Ansible playbook locally on it with my current working user (...
-1
votes
2answers
231 views

Ansible: Difference between the apt module and command: apt-get -y install X (module)

Consider these YAML tasks which are based on two different parts of some locally-executed Ansible playbook I read here: - name: Update the apt package-index cache i.e. apt-get update apt: ...
0
votes
2answers
63 views

Is there a book only about Ansible (without touching Vagrant, VirtualBox, Docker and virtualization stuff)?

I need a book only about Ansible (without touching Vagrant, VirtualBox, Docker and other above-shell stuff). About 6 months ago I tried reading the Ansible docs but these were totally un-...
0
votes
2answers
44 views

What Ansible does in cases there's a conflict between OS version and some software Ansible manages?

Say I use an IaaS cloud on which I installed Ubuntu 18.04 manually via the cloud company's OS installation tool and I ought to establish an all-ansible LAMP environment that will include some more ...