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
18 views

Regex in ansible to check for multiple lines with same prefix

I am checking if few lines are present in a file using ansible. These lines have a common prefix and if all the lines are present in the file i will print "YES" otherwise "no" --- - hosts: localhost ...
0
votes
1answer
11 views

adding remote N number of hosts to AWX

Installed Ansible AWX on CentOS 7 without docker. Want to add remote linux hosts(without password) to AWX and run play books and get the results. How to do it? Can any one help. One or two hosts I can ...
0
votes
0answers
12 views

How to list Ansible managed files in a file on the managed host?

My problem is that administrators like to configure the system directly, and don't want their changes to be overwritten by Ansible. We only have a very small number of servers running different ...
0
votes
1answer
15 views

ansible-pull on remote hosts

I want run the playbook on remote host, which the playbook is in github. So, I followed this blog and forked the repo https://github.com/vincesesto/ansible-pull-example In side the repo, I have ...
2
votes
3answers
33 views

Rename file with version number to file without version number

I want to rename file-name-1.2.3.war to file-name.war I have tried various Ansible modules that would rename a file, but, I could not figure out how to get list of files and remove the version number ...
0
votes
1answer
29 views

Supress Ansible warning (at least for aptitude install)

How can I install aptitude package without ansible warning: TASK [... : APT: Install aptitude package] ******************************************************************************** [WARNING]: ...
0
votes
1answer
16 views

Icinga2 API: How to set all services of a host into downtime?

I am trying to automate the setting and removal of downtimes on icinga hosts. I am currently using the following command: (note that I'm running this in an ansible playbook so {{item}} is the ...
0
votes
1answer
16 views

Take user input and make a new file in multiple lines

I want to take a user input from vars_prompt like:- Enter names:- apple orange and make a new file on a server with this output:- apple orange how can i achieve this using lineinfile or ...
0
votes
1answer
22 views

Ansible - 'delegate_to' times out to connect to remote host

I am trying to run command on remote host from another remote host using 'delegate_to' and both hosts are linux. Connection is successful when sshing directly on each server, but not from Ansible. ...
0
votes
0answers
19 views

No ansible roles were found in Satellite 6.4 - system roles installed

I have an RHN Satellite 6.4 Server and have installed rhel-system-roles as per documentation. yum install rhel-system-roles But when I click inside the GUI on Configure->Ansible->Roles I get the ...
1
vote
2answers
28 views

Convert list of objects (string, string) into Dictionary (string, list<string>) in Ansible

I have a list of objects (each object contains two attributes of type string) which I need to convert into Dictionary. The first attribute of the object will become a key, the second attribute of the ...
0
votes
1answer
27 views

Calling JSON file into ansible playbook when running playbook locally

Trying to run a playbook locally with some variables such as username,password and IP. Want to store them locally on my machine and call into playbook.How can we do it? --- - hosts: localhost name:...
0
votes
0answers
12 views

Restore or regenerate globals.yml & passwords.yml

I had OpenStack installed for 2 weeks and when I restarted my server this morning I found out that the passwords.yml & globals.yml wasn't in /etc/kolla anymore. I tried using the command kolla-...
0
votes
0answers
13 views

Ansible win_updates fails / no response (Windows Update)

I wrote a playbook with some tasks, running windows update on several servers. To update these hosts, I use the ansible module which works with Windows Update API. Playbook and tasks look like: Code/...
0
votes
1answer
25 views

How to call a variable of string with spaces in a terraform provisioner?

I am trying to run terraform provisioner which is calling my ansible playbook , now I am passing public key as a variable from user . When passing public key it doesnt take the entire key and just ssh-...
0
votes
1answer
18 views

How to make ansible loop over hosts sequentially

I have set of tasks that i want to execute at set of hosts sequentially. Example is below. hosts: all tasks: - name: do some work include_tasks: tasks_here.yml loop: "{{ vars[play_hosts] }}" ...
1
vote
0answers
38 views

Regex Match for fetching Pool Names from the F5 LTM command output

I'm trying to build a custom filter in ansible that would consist of regex match to obtain the pool information from the below output. Regex Tried : ltm\s+virtual\s+(\S+)\s+{\s+(?P<parameters>(...
0
votes
1answer
26 views

How to combine with_dict and with_sequence?

I'm trying to check if a JBoss management user has already been created. I have a working play: - name: Check if Management user has already been created shell: "grep -i '{{jbossvars.mgmt_user}}' {{...
0
votes
0answers
21 views

How do I copy built jar from Jenkins to remote server using Ansible scripts?

I have a Maven application which is in a GitHub repo. I have to setup a Maven project pipeline in Jenkins in such a way that after a successful build, the produced jar file would be automatically ...
0
votes
1answer
19 views

Why isn't Ansible able to parse my azure dynamic inventory config file?

I am trying to set up a dynamic inventory for Ansible to use with Azure, but I am getting some messages as Ansible is not able to parse my yaml file. What I did so far: Created Azure Service ...
0
votes
1answer
32 views

Combine distinct list of dict with ansible

I have two list in ansible: toto: - name: titi - name: tata titi: - name: titi ack: true Is it possible to combine these two lists by the name key to get the following: new_list: - ...
0
votes
1answer
15 views

Ansible module for managing DigitalOcean dashboard firewall

I want to manage my DigitalOcean firewall via Ansible. But seems no such module is available in Ansible to manage (add/remove firewall rule) firewall over the dashboard. Currently, we are using UFW ...
0
votes
2answers
57 views

Retrieving contents of j2 template file on stdout

I'm attempting to use Ansible to better manage my Kubernetes configmaps in a multienvironment project (dev, stage, and prod). I've generalized each of the config maps as j2 templates, and I'll ...
0
votes
0answers
13 views

How to print output to Travis Every 5 mins

I have a travis CI build that keeps failing. The error is.. The job exceeded the maximum log length, and has been terminated. I googled possible reasons.. one of which is.. ...If no output is ...
0
votes
2answers
39 views

Ansible regex_replace does not recognize the variable

I am trying to replace a string using regex_replace but I am having an issue with parameters. vars: **mongoURI**: "mongodb://shard1:27017,shard2:27017,shard3:27017/?ssl=true&authSource=admin&...
0
votes
1answer
17 views

Variable with_items and hostvars

I need to pass a dynamic group name info with_items so that i can access a specific fact that is ran from another host. I cannot hard code the group name I tried to set a generic variable that is ...
-1
votes
1answer
24 views

How do deploy a virtual machine using Ansible?

I’m new to Ansible. I can create one VM using Ansible. I’d like to deploy multiple VMs at one go. I’d appreciate any references or guidelines to accomplish this.
0
votes
0answers
20 views

How to see container output when using Ansible's docker_service module with Rundeck

I have a docker-compose that deploys 4 containers, a psql db and some java app's.I'm already using Ansible 2.7.8 with Rundeck 3.0.8 as a GUI to build those app's and everything was fine until i tried ...
1
vote
1answer
35 views

How to make a sum of counted files from node with ansible

I have a process that takes file from an "in" folder and puts them in an "error" folder when the process failed. I have 2 clusters of 4 nodes where this process is running. I want to count files both, ...
0
votes
1answer
17 views

ansible jenkins_plugins mdule : error when playing again a playbook : Jenkins Home not found

I have a problem with the jenkins_plugins module. Within a playbook that pull a jenkins docker image (jenkins/jenkins:lts-alpine) and runs it to install the instance and configure it, I have a task ...
1
vote
0answers
21 views

Remove Exact Block of lines in config file with Ansible

I want to delete a block of text with ansible from a config file. - name: Remove Block Of Text blockinfile: path: /oracle/config/domains/soa_domain/config/config.xml block: | <...
0
votes
1answer
17 views

Execute file on windows host with spaces in path

I have a playbook to upload file on remote windows host and then execute it. Problem is that I have a spaces in path and playbook is failing on "Execute file". Here is playbook: - name: Copy file and ...
1
vote
1answer
19 views

Ansible: overwrite inventory's ansible_host from command line

I have a simple inventory in hosts: dockermachine ansible_host=10.10.10.10 I need to be able to provide any other IP I wish from the command line, overwriting the default, something like: ansible-...
0
votes
0answers
14 views

Set Empty list with --set-string in ansible for helm upgrade command

How can I set an empty list in ansible while running helm upgrade command. I am trying to do something like this - {% if u.value.args is defined %} {% for arg in u.value.args %} --set-string ...
0
votes
0answers
13 views

AWX 3.0.1 how to merge 2 inventories

How to manage a playbook that is executed on a host on one inventories but needs to retrieve host_vars variable from a host on another inventories object. Smart inventory object does not looks to ...
0
votes
0answers
29 views

How to run a task if any of the roles failed?

We are having our validation tasks defined in roles. - name: validation Operations hosts: all become: yes gather_facts: yes serial: 1 roles: - StorageArray_setup_cleanup - ...
0
votes
2answers
30 views

Ansible: obtain group members taken from a variable

Usually, if I have a group called mygroup, to obtain all members in this group I'm using: "{{ groups.mygroup }}" I'm wondering how I can do the same when mygroup is taken from a variable. I tried "{{...
0
votes
1answer
18 views

Is there a way to set up an SSH connection (pass-wordless login) between host A and host B while running playbook from hostC using ansible only?

I am trying to set up a passwordless login (copy id_rsa.pub from server A to server B) from server A to server B while running a playbook from controller machine C. The playbook: cannot have an ...
1
vote
1answer
41 views

Ansible until loop with regex in conditional statement

I need to check command stdout with a regex pattern in until loop. When I using regex_search to display debug msg all works fine: - name: Checking if node is ready shell: "kubectl --...
0
votes
0answers
46 views

Ansible failing when being used async

Im using ansible to provision multiple instance over aws or other cloud provisioner. This is done with the python API ansible provide. If a run playbooks in a sequential manner it works fine. By ...
0
votes
1answer
24 views

azure-arm Windows VM provisioning with Ansible

Is it possible to use Packer on a Mac to create a Windows VM on azure-arm with Ansible as provisioner? Is there a working example on Github?
0
votes
0answers
38 views

kubespary:ansible can't send data with ssh to a node in ansible-playbook command

in step 10 of tutorial https://dzone.com/articles/kubespray-10-simple-steps-for-installing-a-product for deploying a production ready kubernetes cluster with kubespray, an error occured when running ...
1
vote
2answers
33 views

ansible - customize list content based on condtion in role default vars

I'm looking to defined a list of dict in the default main.yml of a role base on a condtion. Do You know how to do so? I've tried that: pkg: "[ {% if 'web' in group_names %} ...
1
vote
1answer
32 views

ansible behavior to specific sudo commands on managed nodes

Here to discuss the ansible behavior when user at managed nodes is given sudo privileges to specific commands. I have sudo privileges on remote managed host [rm-host.company.com] to specific ...
-2
votes
1answer
18 views

Getting error when trying to integrate ansible with checkpoint Management server

I am trying to integrate Ansible with my Checkpoint Management Server. Ansible is running on ubuntu 18.04.2. PFB the error when i run ansible-playbook ansible-cp-test.yml PLAY [GW] *****************...
0
votes
2answers
23 views

Is it possible to merge anisible group_vars, if possible can you hlep me how to solve

Actually I have group_vars, I need to merge those vars, can you help me. group_vars/eu/main.yaml mgmt_routes: Tok: - ip: 172.22.203.253 netmask: 255.255.255.255 group_vars/all/main.yaml ...
2
votes
2answers
50 views

Ansible: Run command as different user but not with sudo

My overall aim is to restart pulseaudio for a specific user via ansible (so if you have a better idea how to do this, I am open to hear it :) ) I want to run the following command as the user myuser, ...
2
votes
2answers
49 views

Parse Brew Doctor Warnings with Ansible

I want to parse brew doctor result of files into a ansible var list Brew Doctor gives the following Warning: The following directories are not writable by your user: /usr/local/Cellar /usr/local/...
2
votes
1answer
45 views

Fail task/play when host not reachable Ansible

I have written a playbook which copies a file from source to destination on multiple hosts. The playbook works if all hosts are reachable but it doesn't fail if one of the host is unreachable. ...
0
votes
0answers
15 views

Ansible command in python using popen [duplicate]

I have below command that I need to run using python myCmd = os.popen('ansible-playbook playbooks/test.yaml --extra-vars "group_names=host1 arg1=hello arg2=hello arg3=hello"').read() print(myCmd) ...