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
1 vote
1 answer
636 views

Ansible cli_command loop register issues

I can't seem to get the register to works with cli_command and looping of multiples commands. Any suggestions? - name: Run show commands hosts: - all connection: network_cli gather_facts: ...
chester's user avatar
  • 11
2 votes
1 answer
364 views

Using ansible to update remote Ubuntu servers that have no external internet access

I am quite new to Ansible, and have to been able to use it to install packages on 80 remote Ubuntu servers that have no external internet access. Is it possible to use Ansible to update/patch these ...
tango91a's user avatar
1 vote
1 answer
91 views

Strategies for sharing Ansible vaults with root/administrator credentials?

Historically we've been a one man devops team and stored all our passwords in Ansible vaults - including things like domain admin passwords and root account passwords. However we're now growing and ...
Brad's user avatar
  • 111
0 votes
1 answer
159 views

Kubernetes deploy workflow

I have an application (Django web app alongside couple of microservices) and have done deployment previously via Ansible tasks. Playbook was invoked from Ansible Tower and essentially breaks down into ...
Most Wanted's user avatar
1 vote
1 answer
289 views

How can I add an apt-key without using the hardcoded url in an ansible playbook?

I am completely new to ansible this is my second day working with ansible, What I'm ultimately trying to do is configure a kubernetes cluster which has a master node and one worker node. But my ...
user2152012's user avatar
3 votes
2 answers
819 views

How to use facts from one host to perform actions on another host?

In Ansible I'm trying to generate a variable from a task on one host and then use the variable to do something to another host. Specifically, I'm trying to create a Kubernetes cluster - On the control ...
Jim ReesPotter's user avatar
1 vote
1 answer
688 views

ansible-playbook: how to dynamically, conditionally set a large deployment environment (variable space) in a playbook?

I am using an ansible playbook to deploy a php web application in aws. The deployment is repeated many times, with a different environment, for each customer. The different scenarios range from ...
Life5ign's user avatar
  • 130
1 vote
1 answer
132 views

Are package facts getting invalidated automatically when I install remove packages?

In Ansible I can use a task such as: - name: Gather the package facts package_facts: manager: auto to gather the package facts and a condition such as: when: "'foobar' in ansible_facts....
0xC0000022L's user avatar
1 vote
1 answer
369 views

Ansible Playbook fails start Apache Cassandra

I have been tried ran a Ansible Playboo, but after change the cassandra.yml when the service tries start I received this error bellow: ● cassandra.service - LSB: distributed storage system for ...
Vader's user avatar
  • 466
0 votes
1 answer
282 views

Unexpected type error in ansible community.aws.cloudfront_distribution: "origins" parameter: "'list' object has no attribute 'get'"

I get an unexpected type error, for what I assume to be the "origins" argument to the community.aws.cloudfront_distribution module: "Error validating distribution origins: 'list' object ...
Life5ign's user avatar
  • 130
2 votes
1 answer
449 views

Ansible - Variable expansion inside hostvars declaration?

I have a hardcoded hostvars line, like so: node1_hostname={{ hostvars['192.168.0.162']['node1_hostname'] }} I have a set_fact variable from a previous play that I'd like to expand in the host section ...
synth45's user avatar
  • 71
2 votes
3 answers
2k views

Add item(s) to yaml array only if defined (ansible)

How do I write a yaml file such that it defines an array with a list of values, and it skips those values from being added to the yaml array if the given value is undefined? Specifically, I'm trying ...
Michael Altfield's user avatar
2 votes
1 answer
455 views

Problem with Ansible Asynchronous actions

I'm trying to run two simple tasks Task A starts an Ipref3 server and waits for a client to connect Task B starts to run from host-1 until the given timeout once Task B (host-1) is over another Task B ...
Hanoch's user avatar
  • 23
1 vote
2 answers
1k views

ansible & jinja2: How to reference JSON structure items whose keys are variables?

I am using ansible's community.aws.iam_server_certificate_info module to get information about a server certificate on aws ec2, and registering it as a variable "server_cert_info_result" ...
Life5ign's user avatar
  • 130
1 vote
1 answer
339 views

Looping an Array with Missing Keys in Ansible Tasks

I'm attempting to create an Ansible Role to create users... I want it to be able to accept a list of dicts and if a key is missing from the dict, it will fall back to Ansible's default. For example, ...
user1960364's user avatar
1 vote
1 answer
201 views

Ansible - Azure resource referencing

My aim is to have my vnet and subnet in a seperate resource group from the other parts of my infrastructure i.e Virtual Machines. I have a short playbook that creates the resource group for my network ...
user808's user avatar
  • 21
0 votes
1 answer
561 views

How can we prepare GitLab runners using Ansible deploys

Given We run an in-house GitLab server, with many projects (aka "repositories") We provision all servers using Ansible (and deploy projects using pip) We deploy to dev.project.example.com ...
jalanb's user avatar
  • 83
1 vote
1 answer
32 views

trying to display 3 - 5 commands

I was trying to display a few commands with .stdout - the gives me the mixed output also with "item" with item it gives me: just the strings: uname -a uptime but not the output of those ...
Michael's user avatar
  • 11
1 vote
1 answer
49 views

Ansible hosts group reference does not work

I'm trying for hours already to run a docker installation on a specific group of hosts. This is my hosts.yml all: hosts: 01-dev: ansible_host: <IP1> 02-dev: ansible_host: &...
dfsg76's user avatar
  • 207
4 votes
1 answer
5k views

Managing state (e.g. presence/absence) in Ansible, any established best practices?

Ansible lists a nice set of best practices in its documentation. One of the items is: Always mention the state For many modules, the state parameter is optional. Different modules have different ...
0xC0000022L's user avatar
1 vote
1 answer
132 views

IaC Deployment in Azure with Terraform + Chef vs. Puppet vs. Ansible for Data Engineers

I am an Azure Data Engineer and try to leverage the IaC benefits in this area of Azure Data Factory, Azure Databricks, Azure SQL & Synapse, Azure Power BI, Azure IoT. After some research I figured ...
Pirvu Georgian's user avatar
6 votes
1 answer
5k views

Ansible: register variable with loop

What’s the best way to use registered variable ‘audit_tools’ to check if all items are own by root ? Do I need to use Jinja2 filter or something ? Thanks - name: Verify audit tools are own by root ...
sudoi's user avatar
  • 61
0 votes
1 answer
1k views

Ansible No such file or directory error message for any executable in Amazon Linux AMI

I'm trying to run this command in a Amazon Linux AMI instance - name: Run docker shell: systemctl enable docker && systemctl start docker And receiving this error message "stderr&...
Joao  Vitorino's user avatar
1 vote
1 answer
475 views

Using a combination of Terraform and Ansible to create dynamic AWS EC2 infrastructure

The company I work for wants to prevent provider lock-in adn therefore told us to use Terraform+Ansible instead of Cloudformation. We already decided to use terragrunt as an addon. While the ...
Marged's user avatar
  • 163
1 vote
0 answers
59 views

Power on AWS EC2 hosts by specifying their ansible hostnames

I have inventoried my AWS EC2 hosts using the ansible Ec2 inventory plugin. I would like to be able to power on hosts that are currently powered off, by specifying hostname patterns in ad-hoc ansible ...
Life5ign's user avatar
  • 130
3 votes
2 answers
4k views

How to store/retrieve multiple ansible-vault passwords within/from a single file

Update: As @yaobin pointed out. It appears they removed the part about the multiple passwords being in a single file. It was here as can be seen from web archive: https://web.archive.org/web/...
yurtesen's user avatar
  • 130
0 votes
1 answer
5k views

Ansible URI module and skip SSL validation

I have a playbook which looks like - name: CURL post example uri: url: "https://dev-box.local/api/" method: POST body: '{ "max_conns": 0, "...
JackTheKnife's user avatar
0 votes
1 answer
139 views

Error 502 before execute Ansible playbook

I execute an Ansible playbook with an ansible user. The playbook executes properly, with no errors in the application log, no errors in the Ansible log. This .war usually deploys with user "...
Andrew De leon's user avatar
1 vote
0 answers
460 views

Docker mount volume on SELinux enabled server

I'm trying to run Nginx as the docker container on SELinux enabled server with mounted configuration as -v /host/path/nginx.conf:/etc/nginx/nginx.conf:Z That works fine till I will deploy updated ...
JackTheKnife's user avatar
0 votes
1 answer
2k views

Ansible multiple commands to a file

You can see bellow how it looks like my Ansible Script. My question is what i need to change to get output from multiple commands to a file.The problem is that i get output only from the first command....
user28132's user avatar
0 votes
1 answer
50 views

SSL Expiration Date

I play this playbook to get amount of days between two expiration certificates dates: --- - hosts: localhost gather_facts: no connection: local tasks: - name: Save the old date shell: ...
Med's user avatar
  • 5
1 vote
0 answers
20 views

Redirected `ansible-doc -s` output gets weirdly formatted

I'm preparing for Ansible certification, and I decided that ansible-doc -s may be useful to speed up creation of playbooks. It dumps a snippet of configuration of the requested module, with all ...
caxcaxcoatl's user avatar
2 votes
0 answers
1k views

Ansible/AWS dynamic inventory -- How to create groups based on tags?

I am trying to create custom groups, based on tags. I am using this doc as a reference: https://docs.ansible.com/ansible/latest/plugins/inventory.html#inventory-plugins As a baseline, in my aws_ec2....
synth45's user avatar
  • 71
2 votes
2 answers
1k views

Ansible - merging inventories to share variables across?

Is it possible to merge inventories so I can share variables across them? Let's say I have two inventory files. Inventory A and Inventory B. They are both in a directory called inventories. Variables ...
synth45's user avatar
  • 71
0 votes
1 answer
11k views

Ansible playbook error: "Connection timed out during banner exchange"

I am trying to connect to my bastion host and then tunnel that ssh connection to connect to a jenkins host but keep running into the connection timed out error. The error message in full is: fatal: [&...
Imp0sterSyndromeSufferer's user avatar
2 votes
1 answer
3k views

Pass Ansible parameters to include_role

I have a role that contains this task: - name: Download something via Git include_role: name: git_cached vars: params: repo: https://somerepo dest: /some/path I would really ...
Ryan O.'s user avatar
  • 275
1 vote
1 answer
1k views

Ansible dynamic inventory using AWS plugin -- how to obtain internal DNS records or private IP?

Seeking help from those who've worked with dynamic inventory in Ansible. I have Ansible set up with the aws_ec2 plugin (not using the python script as it's been too problematic). Currently, I'm only ...
synth45's user avatar
  • 71
0 votes
1 answer
6k views

Convert AnsibleUnsafeText to String

I am using the ansible shell module to compare the chain of 2 SSL certificate with openssl (they have the same chain): openssl x509 -issuer -noout -in Certiticate1 openssl x509 -issuer -noout -in ...
Med's user avatar
  • 5
0 votes
1 answer
641 views

Ansible fails in Jenkins pipeline when run from docker

I'm trying to deploy a build via Jenkins pipeline using agent docker and Ansible playbook but it fails on Gathering Facts stage as shown below: TASK [Gathering Facts] **********************************...
JackTheKnife's user avatar
1 vote
1 answer
52 views

Ansible: Detecting in parent role when meta dependency role had change

I would like to make an ansible role that drops some credentials into /etc for a few services that are running. Each service is slightly different and requires different mechanisms for restarting to ...
rrauenza's user avatar
  • 137
0 votes
1 answer
1k views

How to skip rest of hosts when item found in host - Ansible

I have a list of hosts using aws_ec2 and I want to find the first host where the ec2 instance has a specific docker container. I created a play book with a list of tasks, which ultimately executes a ...
Will Huang's user avatar
6 votes
1 answer
21k views

ansible error: skipping: no hosts matched

I've tried a few variations on running ansible locally as a test case: nicholas $ nicholas $ ls ansible.cfg ansible.cfg.orig first_playbook.yml inventory.txt playbook.yml nicholas $ nicholas $ ...
Nicholas Saunders's user avatar
0 votes
2 answers
2k views

network ansible command error: "msg": "network os centos is not supported"

How do I get the ansible config for rolly below? remote: [nsaunders@rolly ~]$ [nsaunders@rolly ~]$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: ...
Nicholas Saunders's user avatar
11 votes
3 answers
16k views

ansible: difference between a variable and a fact

While I'm using Ansible for quite some time, I'm not sure I really understand the differences between a variable and a fact. Would it be any difference doing - set_fact: nginx_ssl: /etc/nginx/ssl ...
Baptiste Mille-Mathias's user avatar
1 vote
2 answers
10k views

Ansible: Run tasks on specific hosts with var/fact from another host

I'm trying to get the output from a command on the first host in group managers and execute it on the other hosts in the same group. hosts file [managers] k8s01 k8s02 k8s03 [workers] worker1 worker2 ....
Joao  Vitorino's user avatar
0 votes
1 answer
623 views

The ansible_local var is not being populated when using the setup module to gather custom facts on windows

The ansible_local var is not being populated when using the setup module to gather custom facts on windows. Playbook: --- - name: Testing and Debug PB hosts: all tasks: - name: Gather Facts ...
AlexV's user avatar
  • 1
3 votes
2 answers
518 views

Can we use Ansible for monitoring configuration?

I understand how Ansible works and what it is used for. However, I was wondering if there is a way or feature (in open-source or enterprise edition) in Ansible using which, we can make sure that the ...
Amit Yadav's user avatar
0 votes
2 answers
2k views

How are ansible playbooks supposed to be imported into a collection?

I'm trying to develop a reusable collection of playbooks that I can run from docker containers. I don't want to share duplicate code between containers and I don't want to have containers that run ...
Peter Turner's user avatar
  • 1,376
-1 votes
1 answer
618 views

AWX cannot find matching host

I have on premise AWX and inventory (instances on AWS). To provision newly launched instance I want to use provisioning callbacks. But when executing this command from the instance $ curl -v -H '...
Most Wanted's user avatar
3 votes
1 answer
10k views

How do I make ansible-playbook log its output in a machine readable format like xml or json?

Looking for information on how to output machine readable output form ansible-playbook.
CLJ's user avatar
  • 155

1 2
3
4 5
9