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
2 votes
2 answers
110 views

How to use edited inventory file?

I have workflow with 2 templates. First I add new host to my hosts.ini file: - name: Add to host file blockinfile: path: /var/lib/awx/projects/_52__glusterfs/hosts.ini block: | ...
Danylo Mysko's user avatar
3 votes
2 answers
4k views

Ansible configure and compile in directory

So I have have an Ansible Task that extracts a programs sourcecode zip into a certain directory and is then supposed to compile and install it. The extraction of the zip works fine, but then I need to ...
Kyu96's user avatar
  • 105
0 votes
2 answers
887 views

How deploy public key to newly created VM on GCP?

I create VM instance using ansible module gcp_compute_instance My code: --- - name: Create jenkins node-1 hosts: localhost connection: local gather_facts: no vars: address: <my ip> ...
Danylo Mysko's user avatar
2 votes
1 answer
89 views

How to verify hashes of Ansible Galaxy dependencies?

From a security perspective, I don't like the idea of relying only on Git tags, as they could be moved later. Unfortunately, I'm not aware of an official solution to enforce checks. This is the best ...
Philipp Claßen's user avatar
20 votes
1 answer
13k views

Ansible: What's the difference between task, role, play and playbook?

Ansible has tasks, roles, plays and playbooks. Are those just names for different levels in a playbook organization? If not, how, exactly, do they differ from and relate to each other?
caxcaxcoatl's user avatar
2 votes
1 answer
525 views

How I can use multiple hosts in AWX playbook?

I have workflow that create 2 virtual machines on GCP. When virtual instance created I store output with external ip to variable. In next playbook i want to use all of my ip addresses in host section. ...
Danylo Mysko's user avatar
1 vote
1 answer
141 views

Where do I use Ansible and where is Terraform used? ( Strengths & Weaknesses) [closed]

What is Ansible mainly used for? Where do I use Terraform? This question focusses on where the tools have relative strengths or weaknesses. For example: Ansible for VM build and Software ...
user287144's user avatar
1 vote
2 answers
158 views

Given a blank slate, tool recommendations? [closed]

so I have 8 months of DevOps experience previously working as a desktop engineer for two and a half years.Starting a new role in the education sector, recently they brought their IT department which ...
Nabil Aziz's user avatar
1 vote
1 answer
1k views

How to make sure the specified Azure vm size available?

I am trying to create a VM with a playbook like this: tasks: ... - name: Create VM azure_rm_virtualmachine: resource_group: AnsibleResourcEGroup name: AnsibleVM vm_size: ...
Koala Yeung's user avatar
2 votes
1 answer
732 views

How to programmatically generate docker-compose file?

I am writing an Ansible playbook to deploy services to a clustered environment. There are 3 types of hosts (Application, Load balancer, database). Services are deployed via docker-compose on each host ...
user2818782's user avatar
4 votes
1 answer
205 views

Why is developing Ansible Playbooks using Roles a best practice?

It's a best practice to develop Ansible Playbooks with reusable roles. From what I've seen, people end up putting all their roles into a single complex files anyways. So it doesn't really fix the ...
QuestionTime247's user avatar
2 votes
1 answer
379 views

Check connectivity of 5000 + servers from ansible and get list of hosts which are connectable and which are not

I need to check connectivity of hosts on port 43. I can manually login and check connectivity by: nc -v `hostname` 43 nc -v `hostname_1` 43 Is there any ansible script that goes through all the ...
user12189187's user avatar
3 votes
1 answer
3k views

How to get the device name of a specified mount point with ansible facts?

Using Ansible facts I can get the list of "ansible_mounts": "ansible_mounts": [ { "block_available": 423698, "block_size": 4096, "...
sgargel's user avatar
  • 224
1 vote
1 answer
576 views

Create User Using Ansible with Authenticate Pem File

Community, I am creating a user on the client machine using Ansible but the issue is it creates a user and add authenticate file but getting an error while SSH to that machine using created, User. ...
Shaha Nawaj Mulla's user avatar
1 vote
2 answers
2k views

Ansible resetting swap linux

I am newbie to Ansible, i failed using ansible via command that way : ansible host -a "/sbin/swapoff -a && /sbin/swapon -a" Only this worked ansible host -a "/sbin/swapoff -a ansible host ...
Peutre's user avatar
  • 43
0 votes
2 answers
2k views

How to run Ansible file in Jenkins using Ansible plugin

Please look into this error trying to implement the deploy.yml file with ansible plugin which is installed in the jenkins. In ansible console I can implement the app successfully to the target ...
Akshay Kumar's user avatar
2 votes
2 answers
227 views

Ansible: Test if multiple RDS instances are all stopped

With Ansible, I'm stopping several RDS (it could be EC2) instances. Then I want continue only when all of them are in the state stopped. I use the following task: - name: Wait for RDS modify to ...
jmary's user avatar
  • 171
1 vote
1 answer
257 views

ansible-pull ignore group_vars vault

How do I ignore the group_vars vault file when running ansible-pull? My repository (among other stuff) does machine init, joining the domain and software updates. I would like the software part to be ...
Frank Vermeulen's user avatar
0 votes
1 answer
366 views

Unable to run the playbook in remote machine using Ansible job template. Connection Failed

Playbook.yml --- - name: connectionTest hosts: Windows tasks: - name: "Windows Connect" win_command: hostname register: wincmd_out Variable declared in Inventories Project/inventories/...
G.vigneshwari's user avatar
4 votes
1 answer
160 views

How to handle availability zones and failover with ansible? Is it even within the scope of ansible?

I am only getting started with ansible. I want to set up a new development infrastructure with the infrastructure as code principle. First thing I'll have to prove is a Jenkins instance with a few ...
dfsg76's user avatar
  • 207
0 votes
1 answer
82 views

How does one set up OpenStack Swift (object) storage container-specific API keys with Ansible?

I've got the following OpenStack commands for setting up Swift object storage containers: openstack container create $CONTAINER_NAME openstack container set --property Full-Key=$CONTAINER_API_KEY $...
colan's user avatar
  • 173
0 votes
1 answer
652 views

Loop chmod with Ansible

I'd like to remove the execute bit from some ubuntu motd (Message of the day) files with ansible to disable some ad-like Ubuntu news. The module should only act if files exist and permissions are ...
tdoe's user avatar
  • 11
2 votes
1 answer
1k views

Looping through hosts from an inventory group in a group_vars file

Is it possible to do something like this: # inventories/inventory1/group_vars/group1 filewatches: {% for host in groups['group2'] %} - type: "copy" directory_name: "{{ host }}" ...
FearOfChickens's user avatar
1 vote
1 answer
102 views

Is it possible to have pair of IPs in Ansible?

I have so many HA machines that one of them is primary and the other is standby. I have this playbook that copies a config file from primary and then from standby on local machine then use those ...
BlackCrystal's user avatar
2 votes
1 answer
715 views

Share variables across instances

I'm writing TestInfra test scripts for mongo cluster instances using Molecule Ansible. I want to share variables across all the instances. I created a python class, and initialise and update the ...
Abel's user avatar
  • 121
1 vote
0 answers
89 views

Per machine credentials for privileges escalation using AWX [duplicate]

I have an inventory with a lot of hosts in it using the same credentials, but one host needs a different approach. For the ssh connection a different user is used, after the connection is established, ...
Jonas Hüsser's user avatar
0 votes
1 answer
382 views

ansible error 'first argument must be string or compiled pattern'

I have this code in my playbook: - hosts: standby remote_user: root tasks: - name: replace hostname in config replace: path: /opt/agentd.conf regexp: #\s+Hostname\= ...
BlackCrystal's user avatar
1 vote
1 answer
407 views

Deploy Vm Vmware with simple Ansible playbook

I try to test one simple playbook with ansible. My goal is to create a new VM with it. --- # create a new VM from a template - name: VM from template hosts: localhost gather_facts: false ...
Peutre's user avatar
  • 43
1 vote
1 answer
7k views

Error passing arguments to ansible playbook

I am trying to create a playboook that executes a python3 script with 2 parameters, name and password in localhost. However, when i try to execute the paybook with this command ansible -b --become-...
ras212's user avatar
  • 113
1 vote
2 answers
10k views

Waiting for privilege escalation prompt

I'm new with Ansible so hope to find answers here. I'm trying to run some playbook but getting an error: fatal: [10.65.30.117]: FAILED! => { "msg": "Timeout (12s) waiting for privilege ...
Ronen's user avatar
  • 13
-1 votes
1 answer
70 views

Ansible ec2_vpc_net and ec2_vpc_subnet - where to set subnet default public ip

Since upgrading to these 2 Ansible modules I am having difficulties in setting the subnets to have default public IP when new instances are created by autoscaling? I can't find any setting on the ...
jdog's user avatar
  • 650
1 vote
1 answer
629 views

IOS_Command Module - Delayed Prompt Issue (Cisco 3850 - IOS XE)

I'm new to the Ansible world, so I'll do my best to explain everything. If I leave something out or need to clarify, just let me know. So, I've been working on upgrades for various Cisco switches/...
NetworkThenAutomate's user avatar
0 votes
1 answer
492 views

Ansible - when statement task always return false value

I've got 1 master node from which I would like to instal NewRelic agents remotely depedning on the OS I have on them. Some of them are Amazon 2 Amis and some Amazon 1 Ami. I put when statement in the ...
mbb's user avatar
  • 11
0 votes
1 answer
272 views

Ansible on Ubuntu Core

Ubuntu Core is a minimalistic operating system. It uses snap package manager instead of apt. Is it possible to manage a Ubuntu Core device with Ansible?
mustafa's user avatar
  • 101
1 vote
2 answers
117 views

Prevent misspelled variables passed to Ansible roles

I'm looking for strategies to mitigate silent errors related to misspelled or otherwise mistyped variables being passed to Ansible roles. So for example, I have a role with a defaults/main.yml: ...
Ryan O.'s user avatar
  • 275
1 vote
2 answers
1k views

Ansible fetch all vars files from a directory to generate a combined vars file

What I'm looking for is a task (or tasks) to read whatever .yml files exist in a specified folder and combine them into a file containing all the variables. For example: pets/steves_pets.yml: cats: ...
Sam's user avatar
  • 111
3 votes
2 answers
8k views

using copy module with wildcards

I need to copy a database backup file from a primary server to a standby server. Since I can't use synchronize, I was following this method: copy file to local ansible server from primary, then, copy ...
BlackCrystal's user avatar
2 votes
2 answers
154 views

reboot server during Ansible tasks

I have 3 scripts that must be run on server one by one. for example: - name: find config shell: /data/scripts/config1 become: yes become_user: root tags: find_config - name: change config ...
BlackCrystal's user avatar
4 votes
3 answers
3k views

What are some reasons for using an Ansible role for Certbot vs. Ansible's native `acme_certificate` module?

To get Let's Encrypt HTTPS certificates for their Web sites, I'm aware of quite a few folks using a particular role, which wraps Certbot, a standalone application not native to Ansible. There is, ...
colan's user avatar
  • 173
0 votes
2 answers
1k views

copy contents of file on ansible server to another file on remote servers

I have a bash script on about 70 severs in /opt/zservice/etc/config that i want to change its content with ansible. the new content is on ansible server in this path /data/new_config. how i can use ...
BlackCrystal's user avatar
1 vote
2 answers
137 views

Which Users Should I Create With Terraform And Which With Ansible?

I am creating some Ubuntu VMs in Azure with Terraform. I am then configuring the VMs with ansible. When terraform creates the VM it creates an admin user resource "azurerm_virtual_machine" "main" { ...
opticyclic's user avatar
3 votes
1 answer
8k views

Traverse nested dictionary with keeping the keys in ansible

I'm not able to loop a list in a dict and keep the key of the original dict. Bellow an example of my data vars: nginx_users: 'instance1': roles: - product - ...
maco1717's user avatar
  • 133
1 vote
2 answers
145 views

How to manage the versioning of Azure SQL Databases?

I am looking for a tool that will manage the versioning of Azure SQL Databases, and check for missing schema or migration scripts and apply those changes based on what is missing. Any other solutions ...
smorris's user avatar
  • 11
8 votes
1 answer
4k views

Ansible: Exclude a parameter if variable is not set

Is there a way to exclude a parameter entirely if a variable is not set? I do not want to use a default value for this, I simply do not way the parameter referenced at all. For example, --- - name: ...
Dave L's user avatar
  • 83
1 vote
2 answers
3k views

Ansible nested playbooks with variables

I have an ansible playbook add_dns_record.yml that register the A record and relative PTR of an host to our MS DNS server. - hosts: my_ad_dns remote_user: "{{ lookup('env', 'USER') }}@MYDOMAIN.COM" ...
sgargel's user avatar
  • 224
1 vote
1 answer
252 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 ...
David's user avatar
  • 11
1 vote
1 answer
2k 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....
AVS's user avatar
  • 123
1 vote
1 answer
2k 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 ...
kenorb's user avatar
  • 7,631
5 votes
1 answer
938 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 ...
Yoiro's user avatar
  • 151
0 votes
3 answers
5k 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 ...
Aeseir's user avatar
  • 103

1
3 4
5
6 7
9