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.
441
questions
1
vote
4
answers
324
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
2
answers
849
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
9k
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: &...
0
votes
0
answers
31
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 ...
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&...
1
vote
1
answer
79
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/...
0
votes
1
answer
1k
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 ...
2
votes
1
answer
850
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:...
1
vote
1
answer
430
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>...
1
vote
1
answer
2k
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
...
2
votes
1
answer
551
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 ...
0
votes
1
answer
3k
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: /...
2
votes
1
answer
247
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
│ ...
0
votes
1
answer
215
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
2k
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
400
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 ...
3
votes
1
answer
2k
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 ...
4
votes
2
answers
187
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
1
answer
2k
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 ...
-1
votes
1
answer
480
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!
5
votes
1
answer
3k
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 ...
2
votes
1
answer
132
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 ...
1
vote
1
answer
2k
views
ansible mysql query not showing results
I have used community.mysql collection and was able to run a query against the database.
---
- name: Get stats of a file
hosts: localhost
become: true
tasks:
- name: run mysql query
...
2
votes
2
answers
6k
views
Ansible: How to run local powershell script on remote hosts
I'm trying to write a play that will take a locally stored powershell script from my Ansible server and run it on Windows hosts. I have been using the "win_shell" module to run scripts ...
0
votes
1
answer
36
views
Ansible network automation: log all commands from multiple plays
I'm trying to write a script to publish basic configurations for any new devices. Also to assert compliancy of basic configuration for devices in production.
Trying to gather all the lines executed, ...
3
votes
1
answer
741
views
Where does multi-role variable goes in Ansible?
There are multiple kind of variables in Ansible. And I find it overwhelming to wrap my head around them. Some of them are:
The one we can write in roles//vars/main.yml
The one we can write in the ...
3
votes
1
answer
2k
views
Ansible playbook error: Collection' object is not callable
I am learning ansible on my local vagrant vm machine and I am setting up mongodb using ansible and I keep getting the error:
An exception occurred during task execution. To see the full traceback, use ...
1
vote
1
answer
989
views
Ansible to get AWS SSM Parameter Store value but fail to decrypt secure strings
I need to lookup a value from AWS SSM Parameter Store, but it needs to fail if the parameter type is secure string.
I do NOT want secure string parameters to be decrypted, and I want to detect their ...
2
votes
1
answer
2k
views
How can I determine an Ansible client's IP address in an OS-independent manner?
I have an Ansible environment in which machines are listed by hostname in the inventories. Occasionally, it is necessary to determine the IP address of a target machine in a playbook (note: in this ...
2
votes
2
answers
3k
views
How to loop through json without an array
I am trying to work out how to iterate over some JSON that has repeated structures but have not used a list.
I am using the ansible.posix.firewalld_info module and it returns a dictionary for each ...
2
votes
1
answer
665
views
What are minimum permissions required for an IAM user to provision EC2 instances?
I want to provision an EC2 instance with Ansible. So for that purpose I want to create a separate IAM user to keep things clear.
I can assign the full EC2 access to the user. But I don't want any ...
1
vote
1
answer
1k
views
Ansible Playbook always interactively asks for Become password, even though no become user is specified?
I have a simple ansible playbook that copies a script and executes a script on an EC2 instance.
- name: Playbook Deploy jar
hosts: all
remote_user: ubuntu
tasks:
- name: Copy Provisioning ...
0
votes
1
answer
379
views
Copy and unarchive Ansible Module
I tried below ansible tasks with copy and unarchive modules and facing error
- name: find and archive
hosts: localhost
tasks:
- name: find the file
copy:
src: "{{ item }}&...
0
votes
1
answer
1k
views
How to prompt when win_service service exists?
I'm trying to figure out the steps needed to get when or other conditionals to react when service is present on hosts targeted on my task.
With this I get report that service is on one of the nodes ...
2
votes
1
answer
7k
views
ansible Unsupported parameters for (command) module:
I'm trying to run a shell command in an ansible task but I keep getting an error.
This is the task item and the shell command I want to run:
- name: Set File Watch Limit
ansible.builtin.shell:
...
1
vote
2
answers
623
views
Why does Ansible ignore tasks after failing?
My ansible playbook has a task named 'Copy the build script to the system and run it'. It is prone to errors, so I've created a debug task to debug it:
- name: Copy the build script to the system and ...
7
votes
2
answers
5k
views
Testing for EL with Ansible facts; distribution or os_family?
Sometimes in an Ansible playbook, you'll want to condition running a task on whether or not the distribution is CentOS, RHEL, etc, or if it's something else. A very common example is when a package is ...
0
votes
1
answer
56
views
Ansible user_module exit with "rc: -25" if UID is large
Ansible user_module exit with rc: -25 if trying to create user with UID provided from Active Directory (AD) domain controller (DC).
main.yml
- name: Configure local user for example.com
user:
...
0
votes
1
answer
165
views
Ansible Tower on a Free Linux Distro?
Red Hat's Ansible Tower's documentation states that it can only be run on Red Hat Enterprise Linux. I can see once upon a time it could be run on other distros, such as Ubuntu. Is there a free Linux ...
1
vote
1
answer
714
views
How to check the status of Ethernet port using ansible?
I want to check status of Ethernet port whether it is up or down on remote server using Ansible?
2
votes
1
answer
2k
views
What do skipped, rescued, and ignored results mean in ANSIBLE playbook execution?
What do skipped, rescued, and ignored results mean in an Ansible playbook execution?
What would be a possible scenario where these results would be different from 0?
PLAY RECAP ************************...
1
vote
2
answers
143
views
Dynamic environments per client, which is the best approach, if any?
I don't know how to explain this problem better, but I'll try to explain it clearly:
Where I work our customers are companies, with lots of users
We offer a SaaS solution for them to manage stuff
For ...
1
vote
1
answer
273
views
How can I detect if an Ansible playbook is executed by ansible-pull rather than ansible-playbook?
I am looking for a when condition which is fullfilled when the playbook is executed by ansible-pull.
1
vote
1
answer
631
views
Can not install mysql client and server using a playbook Ansible
Do you know how I can fix this error?
I'm getting 404 response from my node machibe when I'm trying to install default-mysql-client and server using Ansible-playbook apt module or shel.
Facts
I do ...
1
vote
1
answer
485
views
Ansible with OpenSUSE transactional server
When using an OpenSUSE transactional server, transactional-update must be used instead of Zypper. Is there any way of doing this with Ansible?
1
vote
1
answer
2k
views
How to add a string to a line when it doesn't exist?
I'm trying to solve a problem where I want to add a setting 'pci=noaer' to all kernel definitions in /boot/grub/grub.conf, but only if the setting doesn't exist. I've managed to get the basic ...
1
vote
1
answer
169
views
Root ssh key for ansible control node
Scenario: Deploy 30 VMs using terraform and then run ansible - how many ssh keys do you generate? Virtual machine definition in terraform requires administrator ssh key or password provided.
Do you ...
1
vote
1
answer
212
views
Ansible: Does the `hosts: all` pattern in a play only match hosts specified in inventory, or does it also match playbook `add_host` hosts?
I know "all" doesn't match the implicit localhost; the title succinctly expresses my question.
Motivation: I have a playbook that needs to be run on cloud hosts generated dynamically and ...
1
vote
1
answer
685
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: ...
2
votes
1
answer
445
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 ...