Hot answers tagged

5 votes

How can I determine an Ansible client's IP address in an OS-independent manner?

Q: "IP address Ansible control machine uses to connect to the client machine." A: Find out to which IP the client resolves, e.g. running at the controller - debug: msg: "{{ ...
user avatar
4 votes
Accepted

How to loop through json without an array

Q: "How can I iterate over each zone?" A: Convert the dictionary to a list, .e.g. given the data in the variable result - debug: var: item loop: "{{ result....
user avatar
3 votes

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

Generally, things like Packer and Terraform handle most straight infra requirements best in the cloud. Of course, if you have kubernetes up already, it’s the same deal. A packer (or other AMI) image ...
user avatar
3 votes
Accepted

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

What value does Ansible have in a modern cloud environment? As the comments say, it depends on your needs. But I think there is value in considering this sort of thing, so I'm going to answer this ...
user avatar
  • 1,728
3 votes

Where does multi-role variable goes in Ansible?

See Variable precedence: Where should I put a variable?. You can see that the role's defaults represent the lowest precedence for variables and the extra variables, declared on the command-line, ...
user avatar
3 votes

What do skipped, rescued, and ignored results mean in ANSIBLE playbook execution?

For example, the play below - hosts: localhost tasks: - name: Task will be SKIPPED debug: msg: You will never see this message. when: false - name: Failed command will ...
user avatar
2 votes
Accepted

Ansible: Does the `hosts: all` pattern in a play only match hosts specified in inventory, or does it also match playbook `add_host` hosts?

Q: "Does the hosts: all pattern only match hosts specified in inventory, or does it also match add_host hosts?" A: Simple test shows hosts: all includes also added hosts by add_host. In the ...
user avatar
2 votes

Ansible cli_command loop register issues

There are a couple of things here: The indent of "with_items" on the debug module is wrong, it should the same level as the "debug" word. More importantly, in this case the "...
user avatar
2 votes
Accepted

Ansible playbook error: Collection' object is not callable

Note: this answer will very likely and quickly become obsolete when a new version of the community.mongodb collection is released The current version (i.e. v1.3.2 at time of this writing) is not ...
user avatar
2 votes
Accepted

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

To be evaluated, a variable must be closed in quoted double curly braces, e.g. - hosts: "{{ hostvars.localhost.aws_instance_host_group }}" The dot notation simplifies the code. Minimal ...
user avatar
1 vote
Accepted

ansible-doc command for filters & plugins

The command ansible-doc Displays information on modules installed in Ansible libraries. It displays a terse listing of plugins and their short descriptions, provides a printout of their DOCUMENTATION ...
user avatar
  • 142
1 vote

Container deployment sync problem with Ansible

You want the wait_for or wait_for_connection modules. If your playbook consists of a single play, which starts the container, then loads data into it, but still targetting the docker host, then you ...
user avatar
  • 3,058
1 vote
Accepted

ansible mysql query not showing results

The community.mysql.mysql_query module documents its return values as: executed_queries query_results rowcount So, if you're registering r_query, and you want to see the result, you can call r_query....
user avatar
  • 3,058
1 vote
Accepted

Ansible: How to run local powershell script on remote hosts

This is easy if you reference the module in Ansible correctly. - hosts: "TimeMachines" tasks: - name: Calibrate Flux Capacitors script: "scripts/calibrate_flux_cap.ps1 -...
user avatar
1 vote

Ansible: How to run local powershell script on remote hosts

I've found a half-solution to this. You can load a file in to a Ansible variable and use that. So instead of having an inline script, you could store your local script file in to a variable string and ...
user avatar
1 vote

Ansible to get AWS SSM Parameter Store value but fail to decrypt secure strings

One way is to get the value twice, with decrypt=false and decrypt=true, and compare them. - name: Get the value from AWS Parameter Store set_fact: var_value_decrypted: "{{ lookup('aws_ssm', ...
user avatar
1 vote

How to loop through json without an array

Since Vladimir answered this in the ansible context I'm going to give you a way to process this in the shell. As a one liner: for zone in public work; do echo "another iteration"; cat fw....
user avatar
  • 1,728
1 vote

What are minimum permissions required for an IAM user to provision EC2 instances?

quick answer: - The user will need the permissions to execute the ec2 run-instances command. Explanation on how to do this: First create a policy (not Role) that authorizes the EC2 RunInstances ...
user avatar
  • 148
1 vote
Accepted

Ansible Playbook always interactively asks for Become password, even though no become user is specified?

You are explicitly asking to be prompted for the privilege escalation password by running -K which according to the docs is: -K, --ask-become-pass ask for privilege escalation password Try running ...
user avatar
1 vote

Copy and unarchive Ansible Module

You are registering the output of the copy module in the result variable. When the copy module runs in a loop, it returns a results key that contains each item of the loop. The copy module does not ...
user avatar
  • 718
1 vote

ansible Unsupported parameters for (command) module:

Got it to work with this - name: Set File Watch Limit shell: "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"
user avatar
  • 121
1 vote

Ansible Tower on a Free Linux Distro?

The Ansible Tower Requirements still states CentOS 7.7 or later 64-bit (x86) however you must have valid subscriptions attached before installing and running An other option might be to use ...
user avatar
  • 142
1 vote

How to check the status of Ethernet port using ansible?

Assuming you can connect to the machine (say, using a local connection), you can interrogate the host facts. It should expose a list ansible_interfaces, which will include the name of your ethernet ...
user avatar
  • 3,058
1 vote

Dynamic environments per client, which is the best approach, if any?

From what I understood is that you want add deploy a configMap and a Deployment based on some API calls every time you need to add a new customer? Basically you need a CD Pipeline that triggers a ...
user avatar
  • 111
1 vote

How can I detect if an Ansible playbook is executed by ansible-pull rather than ansible-playbook?

I found two approaches to test if a playbook is applied via ansible-pull: Check for ansible_connection == "local". However this doesnt work in all places as local connections might also ...
user avatar
1 vote

Can not install mysql client and server using a playbook Ansible

Maybe specify other package names that one can see at http://deb.debian.org/debian/pool/main/m/mariadb-10.3/ like: - name: Install Mysql and htop apt: update_cache: yes cache_valid_time: 0 ...
user avatar
1 vote

Ansible with OpenSUSE transactional server

I think currently the only way is to use the command (or shell) module, as there's no native support for transactional-updates in Ansible yet. However, there's a fresh feature request issue: https://...
user avatar
  • 111
1 vote
Accepted

Root ssh key for ansible control node

There are pros and cons for both options: A single master key for your Ansible account would reduce complexity but you would need to ensure the private key is very secure, even if the key were ...
user avatar
  • 150
1 vote
Accepted

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

If I understand the question correctly, the problem isn't really related to ansible at all. What you need is a package repository on the local network that can cache or mirror public packages. There ...
user avatar
1 vote

Strategies for sharing Ansible vaults with root/administrator credentials?

This sounds like you are applying Ansible playbooks locally on peoples workstations. The best way to protect this would be applying the playbooks using a remote system, like AWX or a CI system such as ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible