Newest 'ansible' Questions - Stack Overflow

Questions tagged [ansible]

Ansible is a model-driven configuration management, multi-node deployment/orchestration and remote task execution system. Uses SSH by default, so there is no special software to be installed on the nodes you manage. Ansible can be extended in any language.

0
votes
0answers
4 views

Module get_url results filter

I want to parse specific output from get_url when I pass a list of URLs as a parameter. I know I can get output to the level of {{ get_url_results1.results }} BUT, I'm having trouble parsing output ...
-1
votes
0answers
12 views

Ansible syntax error while executing playbook

My ansible playboob is as follows: --- - hosts: hosts vars: version: 18.7 tasks: - name: COpy war file copy: src: /etc/puppet/warrepo/japp-$version.war dest: /data/dist/app/ tasks: - name: ...
0
votes
1answer
9 views

Ansible PUT request to update only one attribute in API data

I'm trying to update an attribute from a GET API JSON result and do a PUT request along with the entire API data with only one attribute change. Please advice on the format for PUT Req Task ? Get ...
0
votes
1answer
13 views

Creating a directory with Ansible results in file ownership change in /usr/lib/python3.7

Using Ubuntu 19.04 and Python 3.7 When I create a directory with Ansible, file ownership is changed in /usr/lib/python3.7 Obviously this should not happen and it breaks Python for the whole of ...
0
votes
1answer
12 views

Why can Ansible AWX only have one machine credential per inventory?

Is there a reason not to set credentials for each host? When defined multiple hosts in one inventory, is it common sense to share one private key?
1
vote
1answer
15 views

Ansible set_fact dictionary with nested list

I need to be able to convert this: { "529eacea00000003": [ [ { "limitBwInMbps": 0, "limitIops": 0, "sdcId": "2e18899800000000", "...
-1
votes
1answer
18 views

Is there an ansible script that can disable and enable an application script traces?

Now I have a requirement for an application we are currently supporting. So the task is to write an ansible script that will disable and enable the application's script traces (global, local, trace), ...
0
votes
0answers
14 views

Run powershell script from Ansible

I have a powershell script which takes multiple user inputs for file ex.- "C:\temp\foo.ps1", then it runs. I am trying to integrate that script with Ansible using win_shell module. How can I pass the ...
1
vote
1answer
9 views

Loop over subsets of Ansible array

I'm working on an Ansible playbook to automate the deployment of some dashboards in Grafana. I have a large list of items that will go into each dashboard, how can I loop over the array, but in sets ...
-1
votes
0answers
17 views

Ansible doesn't recognize mvn command, but Maven is installed

I'm trying to run a maven project from Ansible Tower, but Ansible kepps giving me a 'mvn: command not recognized' error, mvn runs fine if I do it manually from command line on a Linux server I had a ...
0
votes
1answer
12 views

filter out text from a complex json object created by an ansible register of gentent module using a json_qry

Specifically I want a "string" of account IDs that are missing from a list I give the task on a server in my inventory. I run the getent module in the task and I register the result which seems to be ...
0
votes
1answer
15 views

Ansible: Attach role to user in postgres

I am already having a role in Postgres namely readonly. It has readonly access on all the tables in all the databases. I want to attach this role to a user so that he/she also gets the readonly ...
0
votes
0answers
8 views

Ansible : Add running EC2 instances to Auto-scaling group

I am working on an Ansible project in which I would like to add to my Auto-scaling group an existing EC2 instance found by tag-Name. I was able to find it with an AMI or terminating the old instances. ...
0
votes
0answers
11 views

Jenkins Queue Duplicating Ansible Jobs from Sensu

I am having an issue with Jenkins allowing the same jobs to enter the queue which are being processed. If it is being processed, it should not be added to the queue. The initiator is Sensu which sends ...
0
votes
0answers
13 views

How to get the remaining size on C: with ansible?

I need to get the remaining size of the C: partition, and I have trooble to do it with the win_disk_fact module. The final objective is to check if the remaining size is less than 4GB before ...
0
votes
1answer
24 views

How to Loop multiple tasks based on the condition

I am trying to iterate multiple tasks based on the result from one of the tasks in the child yml file. Since, looping on blocks is not possible, I have included all the tasks in task file and ...
0
votes
0answers
17 views

Ansible - Activating virtual env with become_user

I want to do create a user for my CKAN installation and then activate a virtual environment as the user and install something. - name: Add a CKAN user user: name: ckan comment: "CKAN User" ...
1
vote
1answer
16 views

Is it possible to check from jinja2 if a task is retried or not?

I am trying to implement a retry-in-verbose-mode logic in Ansible but I am not sure if this is possible. Mostly I want to do something like - shell: cmd: some-command {{ if retries '--debug' }} ...
0
votes
1answer
31 views

Modify a line and append if needed

Using Ansible i want to modify an existing configuration file and change a specific setting (variable) depending on one or more vars that i specify in a customer specific playbook. The configuration ...
0
votes
1answer
37 views

How to fetch values from inventory file in ansible?

I'm trying to fetch the values from the inventory host file but unable to get the values. Using ansible 2.5. Thanks in advance. Please help me with the code in jinja2 template form only. Host file: [...
0
votes
0answers
12 views

How to change the name of the network interface with ansible?

I need to change the name of the network interface using ansible. eg. mv /etc/sysconfig/network-scripts/ifcfg-eno1675454 /etc/sysconfig/network-scripts/ifcfg-eth0 nmtui and change the profile ...
0
votes
1answer
29 views

How to modify an existing dictionary in ansible?

I'm trying to add an existing list to an existing dict in Ansible. I have a dict "jbossvars" containing the following (ansible debug) "jbossvars": { "environments": { "TEST_ENV": { ...
0
votes
1answer
22 views

Difference between shell and command in ansible

I am new to ansible world can anyone help me in understanding the difference between shell and command in ansible. When to use shell and when to use command. I know one use case command module is ...
0
votes
2answers
16 views

how to copy directories from remote machines to localhost?

In ansible playbook, fetch module only copies file from target machine to local. copy/synchronize modules can copy directories/files from local to target machine. Then how to copy direcotries from ...
0
votes
0answers
20 views

Retrieve information from remote hosts using reactjs, ansible backend and store in mongodb

My goal is to query remote hosts in regular intervals and get information like OS, kernel version and many more and store it all in mongodb, additionally display it on screen using reactjs. I am ...
0
votes
0answers
21 views

Delegation a set of tasks to another host that relies on conditional

My question is slightly complex. I have some multi-node cluster infrastructure that orchestrated with Ansible. And there can be nodes that Kubernetes masters or slaves. Depending on that I need to ...
0
votes
0answers
50 views

Code of Ansible playbook to create Kubernetes CLI (kubectl) and Azure CLI [on hold]

I created VM, but i want to use ansible playbook to automatically install kubectl and azure cli. I tried this but it is take many time : https://github.com/codecap/ansible-role-kubectl https://...
-1
votes
0answers
20 views

Can I pass in ansible-playbook --private-key (ssh-rsa sdfasdf…==) instead of --private-key (id_rsa)?

What I am trying to do is, to pass the contents of the ssh-private-key directly instead of passing the ssh-key file. I am able to execute the following command to run my playbook users.yml over to a ...
0
votes
0answers
23 views

Ansible mysql crashes on restart service and gets corrupt

After a whole day of trail and error, I came up with a sort of working ansible playbook for makeing a simple LEMP stack for Laravel applications. However, everything succeeds, but I still have ...
1
vote
0answers
38 views

Azure DevOps Running Ansible Playbook

Currently I am having issues with Azure DevOps running Ansible task. The Ansible task would use the command module and run a command locally on itself calling the aws cli api. When Ansible calls the ...
0
votes
1answer
28 views

How to do regex search using variables in Ansible

I am trying to do regex match in Ansible (2.7) using variable initialized at the beginning of the script Variable used for the regex match- group: 12 Following is the line of code that is supposed ...
1
vote
1answer
27 views

Ansible - How to loop through command with items until registered variables are equal?

I'm trying to find if a file has had any writes in the last 15 seconds. - name: 'Check File for Writes' shell: tail -n 50 /path/to/some/file | sha1sum loop: - 1 - 2 register: ...
0
votes
1answer
11 views

Error while accessing variables in vars file in a role

As a follow up to this question How to read a particular part of file in ansible. I am trying to do the same but by using roles. The variables are stored in vars files Here is the vars/main.yml file ...
0
votes
2answers
20 views

Install ansible galaxy using ansible

How do I install an ansible role using ansible? The manual way is using the command line: ansible-galaxy install user.role But how do I do it in ansible itself, like a module? I would guess ...
0
votes
1answer
12 views

How to check for state in ec2_ami_facts

ec2_ami_find is deprecated and ec2_ami_facts have to be used instead. In ec2_ami_find, we had to provide the parameter to check the state which will match the ami state. How can we incorporate the ...
1
vote
2answers
15 views

How to update variables of ansible roles through jinja2 template

I am learning ansible roles and I am trying to set the variables of the roles using Jinja2 template. But the variable values are not being updated. Here's the working directory sample sample ├── ...
0
votes
1answer
19 views

Copy to remote shared path using ansible

I am trying to copy some files to a remote shared path. --- - hosts: localhost tasks: - name: Test copy: src: /tmp/log/test.csv dest: \\xyz_prod.com\public\app\ The playbook ran ...
0
votes
0answers
17 views

Is it possible to deploy MS SQL scripts using Ansible?

We are currently using SqlPackage.exe to create dacpac and deploy the dacpac. Is it possible to deploy the dacpac/sql code using Ansible?
0
votes
2answers
31 views

How to configure users/keys to allow Ansible to run against multiple hosts?

I'm currently using a sandbox environment to help gain an understanding of Linux and Ansible. I have a rhel 7.6 VM where Ansible is installed/ran from that i connect to via moba. I then have 2 test ...
0
votes
1answer
23 views

vars_prompt not working in role - Ansible

I'm trying to automate hostname creation for 10x machines using ansible roles. What I want when executing playbook, as this wait for enter the user name manually. I tried with vars_prompt module ...
0
votes
0answers
18 views

minishift - where to get the ansible playbooks for metrics

I am running minishift locally and want to install metrics on the same. I learned that metrics are removed from minishift and there is a way to enable them through ansible-playbooks. I am not very ...
0
votes
1answer
19 views

multiple variables in same for loop (Jinja2, Yaml)

I have a list in yaml file users: name: - abc - pqr age: - 10 - 12 I want to iterate over above values in jinja2 template. Member in name is associated with member in age of ...
1
vote
1answer
21 views

Ansible list concat contains only the last element when used with a loop

[Closed] It is a bug in Ansible v2.5.1, see comment below. I want to build a new list based on a dictionary. So I try with set_fact and a loop but the variable only contains the last value (not the ...
0
votes
0answers
38 views

How to resolve this fatal error in ansible?

I am not able to start or stop tomcat using ansible. I am trying to stop tomcat on my other system, it gives fatal error but it is able to login through ssh, ping using ansible, create files and ...
2
votes
1answer
24 views

Ansible docker connection with identical container names on more than one host

I'm trying to run an ansible playbook against multiple hosts that are running containers using the same name. There are 3 hosts each running a container called "web". I'm trying to use the docker ...
0
votes
0answers
14 views

Ansible gets error running command, No error if I enter it manually [duplicate]

I'm trying to run a Gradle project with Ansible on a Linux server. If I go into the server and manually enter './gradlew clean deploy' I get no issues. When I run it with Ansible, I'm getting a '...
1
vote
1answer
27 views

Add servers to /etc/exports with Ansible

I'm trying to get ansible to add lines to /etc/exports for each value in the {{ips}} variable and not have them all on the same line. I have tried a few different ways including lineinfile, ...
1
vote
0answers
23 views

Why does the ansible option “--private-key” works on one host but not on another?

I installed ansible 2.8.0 on VM-1 without modifying any other default configs in ansible.cfg except the "host_key_checking = false". Then I ran ansible all -i "<IP of VM-3>," --private-key <...
0
votes
2answers
14 views

Using Consul KV store for inventory details, possible?

Is it possible to use KV information from Consul to populate the inventory during runtime? I would like to pull KV information from Consul when running ansible-playbooks to populate the inventory ...
0
votes
1answer
12 views

Ansible : Newly created/old launch config not found for auto-scaling groups

I am working on an Ansible project in which I am creating a launch config. After that, I am trying to add it to an auto-scaling group. But it always says, launch config not found. what am I doing ...