ansible-play | Group statements in Ansible playbooks | DevOps library
kandi X-RAY | ansible-play Summary
kandi X-RAY | ansible-play Summary
Group statements in Ansible playbooks
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run a module .
- Initialize the embedded playbook .
- Creates a callback for the given attr .
- Load the playbook from a file .
ansible-play Key Features
ansible-play Examples and Code Snippets
Community Discussions
Trending Discussions on ansible-play
QUESTION
I'm trying to do a dry-run of a small test script I've put together for ansible
but I am getting an error.
The script is this:
...ANSWER
Answered 2021-Jun-10 at 07:24Using the command ansible-galaxy collection install community.general
did not work for me, as it did not allow me to use the various modules.
What worked for me was to install the ansible-collection-community-general
from the official repos.
QUESTION
The Script, running on a Linux host, should call some Windows hosts holding Oracle Databases. Each Oracle Database is in DNS with its name "db-[ORACLE_SID]".
Lets say you have a database with ORACLE SID TEST02
, it can be resolved as db-TEST02
.
The complete script is doing some more stuff, but this example is sufficient to explain the problem.
The db-[SID]
hostnames must be added as dynamic hosts to be able to parallelize the processing.
The problem is that oracle_databases is not passed to the new playbook. It works if I change the hosts from windows
to localhost
, but I need to analyze something first and get some data from the windows hosts, so this is not an option.
Here is the script:
...ANSWER
Answered 2021-May-28 at 21:35It might be possible that Ansible is not parsing the updated inventory file file, or the hosts name is being malformed in as it updates the inventory.
In this scenario, you can use the -vv or -vvvv parameter in your Ansible command to get extra logging.
This will give you a complete picture into what Ansible is actually doing as it tries to parse hosts.
QUESTION
I would like to run a playbook from a shell script with variable options.
When I have double quotes around ${ansible_opts}
, running the playbook fails and I get the following error.
What is the problem?
ANSWER
Answered 2021-Jun-07 at 12:40For something this simple, it is probably sufficient to simply let the shell do word splitting by removing the double quotes:
QUESTION
I'm facing a huge slow while managing a specific remote host with a specific role.
I have tracked down the source of the slowness and found that for a very specific variable (defined for that specific host and used by that specific role), ansible
and ansible-playbook
takes up to 30 seconds to build it while for other variables it takes few seconds only.
I have activated verbose mode and checked log file but nothing unusual except that ansible
is completely silent (no logs are added) for a very long time for the problematic variable.
My questions:
- is there a way to debug
ansible
to get the root cause of the issue I'm facing? - anybody can suggest an explanation of this behavior?
Here is the outcome of printing the problematic variable iptables
and another normal variable ifcfg
:
ANSWER
Answered 2021-Jun-05 at 10:54With the help of @Zeitounator
, I have solved the issue.
The iptables
variable is a dictionary with several levels and I have two more variables nets
and ifcfg
that are also dictionaries with several levels.
Many values of iptables
are set with values from ifcfg
that are set using values from nets
.
I have managed to set values in iptables
using values from nets
directly and now the evaluation of iptables
is as fast as the other variables.
QUESTION
I'm rather new to ansible and would like to deploy prometheus-grok-exporter (via ansible-grok-exporter role) with a specific configuration for all my nodes that run the cacti application.
My inventory is like this:
...ANSWER
Answered 2021-Jun-02 at 14:51You can't use this kind of for loop in a variables file or a playbook - it only works in template files. To acheive what you're after, you can use product filters, as described https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#products
In your example, you would have:
QUESTION
Terraform code is below
...ANSWER
Answered 2021-May-27 at 04:57To refer to your module, instead of:
QUESTION
I am writing an ansible playbook to perform various pm2 functions.
I have searched a bit and cannot find an example of someone setting up pm2-logrotate.
I believe I am close but I'm not sure my shell commands are working. When I ssh into the child node and run sudo pm2 ls
it says In-memory PM2 is out-of-date, do: $ pm2 update
even though I am running that command from my playbook. What am I missing here?
ANSWER
Answered 2021-May-24 at 22:03I was mixing up the users on my server. I fixed this by specifying to run as ubuntu for the update command.
QUESTION
I have written a playbook to add one entry in resolv.conf and add a new user. Group I am specifying in not present in target system however I am not getting the error in dry run ( using --check) option but getting it in actual run.
...ANSWER
Answered 2021-May-15 at 19:12The issue is that in check mode, the user
module only checks whether or not the user exists. The solution is to add a task to your playbook that ensures the group exists as well:
QUESTION
I am trying to use the ansible.builtin.lookup plugin in order to read a JSON file from the local directory and then pass it as the payload to the ansible.builtin.uri module to send a POST message to a URI endpoint.
Following are the contents of my JSON file (config.json):
...ANSWER
Answered 2021-May-13 at 01:03You have used to_json
on a dict
value that is, itself, going to be to_json
-ed; ansible cannot transmit a python dict
over HTTP, so any yaml structure that is not already a string needs to be converted into one first
What you'll want is just that lookup result (which will return a str
, not a dict
) and then ansible will apply to_json
to the whole body:
value for the aforementioned reason
However, because ansible is trying to be "helpful", it will auto-coerce a yaml value that it finds starting with {
back into a dict
-- that's why you just need to send the result of lookup
through the | string
filter to reinforce to ansible that yes, you really do want it to remain a str
in that context
QUESTION
I'm currently adding GCP to our ansible system as up until now we've done the lengthy process of creating images, instance templates, groups and deploying them all manually with the CLI suite.
I'm getting stuck on an error with network interfaces trying to create a simple Instance Template using the same parameters we used to do manually.
Error:
...ANSWER
Answered 2021-Feb-23 at 07:31Disclaimer: I have no experience with GCP and nothing to correctly test this against. Meanwhile I have some experience in reading ansible documentation and testing module usage for correct parameters (at least at pure ansible level...)
As I first did, you probably flew over the documentation and its examples a little to fast ;). Meanwhile the specific parameter description is very clear:
network
- dictionary
Hence a str
is definitely not what is expected, as explicitely reported by your error message. We get more information in the comment:
[...] This field represents a link to a Network resource in GCP. It can be specified in two ways. First, you can place a dictionary with key
selfLink
and value of your resource's selfLink Alternatively, you can addregister: name-of-resource
to a gcp_compute_network task and then set this network field to{{ name-of-resource }}
If you look correctly at the examples, you'll see that they demonstrate the second scenario above (creating/registering a network to use the registered var directly in that parameter).
Taking for granted your own example in your question is using a ressource selfLink (have no clue if your current value looks correct or not...), I guess you should modify your definition as follows (abridged to network interfaces only):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ansible-play
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page