Newest 'ansible-2.x' Questions - Stack Overflow

Questions tagged [ansible-2.x]

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems

0
votes
0answers
18 views

How to enable/disable logs and debug using Ansible

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 logs and debug. Any example script or playbook will be ...
-1
votes
1answer
25 views

Is there an ansible script that can disable and enable logs and debug? [on hold]

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 logs and debug Also the script should be parameterized ...
0
votes
1answer
19 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
1answer
25 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 ...
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, ...
0
votes
0answers
17 views

How to transfer the Ansible Tower template to another Tower?

How to transfer the Ansible Tower template to another Tower which includes the project(Git Repository & its credentials)? Any command/API or copy/paste method can get my job done?
0
votes
1answer
39 views

How to perform a cyberarkpassword lookup for all hosts in an inventory group and write the keys out to individual pem files?

Ansible version 2.7.9 I'm writing an ansible playbook to deploy an piece of software to a linux environment. SSH access to these systems is protected by a CPM (Cyberark), used as an ssh key manager. ...
0
votes
1answer
24 views

How to access an ansible block variable in a file from the same block

I define a yml variable files for ansible with the following structure: appserver: root_directory: C:\app config_directory: '{{ root_directory }}\config' it seems the second variable ...
0
votes
0answers
40 views

ERROR! vars file vars not found on the Ansible Controller

ERROR! vars file vars not found on the Ansible Controller. If you are using a module and expect the file to exist on the remote, see the remote_src option. --- # tasks file for user-management - ...
0
votes
1answer
39 views

Ansible: How to set up Ansible so bastion's *SSH config* is used to access target host

Background/goal: I need to run Ansible from my laptop > bastion > a target host b/c target hosts are behind firewalls that I do not control (IOT devices). I have active reverse tunnels between target ...
0
votes
0answers
38 views

Ansible Inventory Grouping

I have ansible filtering option defined with following playbook. But when executed with centos user it is not filtering by user to run. I have to run this playbook 3 times with 3 different user: 1. ...
0
votes
1answer
37 views

Write output of ansible task to file in proper JSON format

I'm trying to write shell task output to json, but I have the problem of parsing it in a valid one json file. This is example of shell task output: {"firstname": "John", "lastname": "Smith", "user": "...
-1
votes
1answer
36 views

How to make Job attribute value based on environment

In ansible cron job definition,how to give job attribute value dynamically based on environment.I have requiremnt need to execute same cronjob with different parameters and to do that right now ...
0
votes
1answer
51 views

Ansible rollback: run a group of tasks over list of hosts even when one of hosts failed

I have a playbook with multiple roles, hosts and groups. I am trying to develop a rollback functionality, that would run over all hosts. My current obstacle is that I see no way to delegate role, ...
-2
votes
0answers
33 views

Ansible - Error while using the become_user feature

When trying to run playbook on remoteHost using user my name/password {myUser/myPassword} way & trying to become sudo user{sudoUser} I am getting authentication error. However the user {myUser} ...
-2
votes
0answers
27 views

Parse through list of dictionaries in ansible

ok: [localhost] => { "changed": false, "connection": "close", "content_type": "application/json", "json": { "items": [ { "name": "...
1
vote
2answers
26 views

Ansible : how to pass “{{ABC}}” as a string

Under my jinja file i ve this line - mockString= "{{ABC}}" My mockString must have the exacte value "{{ABC}}" where the first letter is " , the second is { the third is also { ect... Now when ...
0
votes
1answer
46 views

Using Ansible copy module for remote to remote file transfer (same remote host)

I'm trying to move all files under a specific remote directory to another remote directory - on the same remote host - using Ansible's copy module. The directory, and files, do exist on the remote ...
0
votes
1answer
32 views

Syntax to pass dynamic variables to include_tasks along with with_item in Ansible playbook

Executing parent.yml which in turn calls child.yml playbook for execution with dynamic variables. Variables from parent.yml aren`t interpolated inside child.yml playbook. Correct me if I am using ...
1
vote
3answers
34 views

Ansible - using json imported from Consul

I have a json content on Consul that I import to my playbook. The json contains account names and passwords: { "account_1": "password_1", "account_2": "password_2", "account_3": "...
1
vote
2answers
29 views

Ansible PLaybook: Escape '$' in Linux path

I have a path which looks like this - base_dir/123/path/to/G\$/subdirectory/html/ When I try to set this path in Ansible playbook, it throws error. If add \$ to escape '\', it throws unexpected ...
0
votes
1answer
38 views

Error running playbook with encrypted group_vars

I am trying to run a playbook with a file that has been encrypted using ansible-vault. However, I get the following error: ERROR! Syntax Error while loading YAML. could not find expected ':' The ...
0
votes
0answers
31 views

File copy action with pull option through jump host

Get the file in ansible playbook run that is pushed though jump host. ansible play book run on a host.The host is secured(tier 2) and public domain cannot be accesed, to access public domain there is ...
0
votes
1answer
53 views

How to register a variable when using loop with stat module?

How to register a variable when using loop with stat module? I am working on a project where I wish to run comparisons against the known value of a collection of files (checksum), which I will then ...
0
votes
0answers
25 views

ansible action plugin expand ansible fact

i have been trying to use what is here in order to pass the hostname to a module use ansible_facts in module code i have the code below which normally will create a fact which i can after use with ...
1
vote
1answer
30 views

Ansible parse for a specific line in resulted registered var

Under my ansible playbook , i ve a task which execute a script: - name: Execute Update on selected databases shell: "./script_update.sh server007 {{item}} {{bdd_config[item].updateFile }}" ...
0
votes
1answer
27 views

Ansible : Return a attribute from list, with filter applied on another attribute

I am getting the below dictionary from calling python library called from Ansible. { "replication_detail": [ { "name": "xxx.203.server:11111", "self": true, ...
0
votes
0answers
28 views

How to remove a specific block of lines from prometheus.yml file using ansible?

I have a prometheus.yml config file which have multiple k8s clusters configured for monitoring. Since the servers come and go we need to delete the servers which are deleted from our peometheus.yml ...
-1
votes
1answer
42 views

When using “when” in my playbook, == works but != does not?

hosts: all gather_facts: true tasks: - name: testing statements debug: msg: "{{ ansible_hostname }} is log01 or log02" when: ansible_hostname == "log01" or ansible_hostname == "...
0
votes
0answers
26 views

Running playbook in host A to get value and pass on the value to task where it execute locally

Execute a Task to get the hostname in windows machine and store in variable called HstName. Then I have to use the variable to create a folder in GCP dynamically. My GCP module works only on localhost ...
1
vote
1answer
64 views

I get the message: “The pexpect python module is required” when running pexpect module on ansible

I am very new to ansible and I am trying to run a playbook to change root password of hosts so I am using the expect command of pexpect module. I successfully managed to install pexpect v4.7 with ...
-1
votes
0answers
34 views

Ansible wait_for module is not working for telnet

I am learning ansible and i an using the wait_for module for telnet of remote host to another host. i will provide the master ip when running the playbook . ansible-playbook example.yml --extra-vars ...
0
votes
1answer
28 views

Ansible task is failing even with the right syntax

I am learning ansible and i have written a task for LDAP validation. However, when i run the playbook, the task is failing even when the validation is correct. Below is the ansible task which will ...
0
votes
1answer
25 views

How to execute task on all hosts from group when playbook is executed with limited hosts?

Scenario I have a group A in my inventory, where A contains a1,a2,a3 hosts. It does mean that I can write in my playbook X.yml: - hosts: A roles: - role: name: r The problem is about ...
0
votes
0answers
17 views

Trying to authenticate with GCP storage from windows machine using service_Account

I have service account json file, With file am trying to authenticate with GCP storage. GCP command line works fine, But fails in playbook with below error ERROR after executing playbook TASK [...
0
votes
2answers
24 views

How can I save values into a list var from multiple tasks in ansible?

I have a playbook where I execute several tasks. Each task can be executed if it meets the WHEN condition. I would like to save some data into a list so I can use it later in the process. Here is an ...
0
votes
1answer
121 views

Ansible 2.7.x skipping task: “skip_reason”: “Conditional result was False”

Ansible is skipping the execution of a task even when my conditional string is meeting the requirement and I can see this string in the stdout. I tried playing around with the content option in copy ...
1
vote
0answers
45 views

Ansible 2.7.10 got error with communication with rabbitmq 3.8.7

I have Ansible 2.7.10 with python 3.6.7 on Ubuntu, RabbitMQ 3.8.7 with Erlang 21.3 on Windows 2019 Core. I want run simple task like: ansible rabbit -m rabbitmq_vhost -a "name=/test state=present" ...
1
vote
0answers
31 views

how to fix issue with ansible win_hotfix module

I'm writing a ansible playbook for installing hotfix in windows 2016 using network share as source in win_hotfix module for ansible. I wrote below mentioned playbook for that. I am running ansible in ...
0
votes
1answer
54 views

How to skip role when host is unreachable?

I have disable_root role, which creates admin user and disables root user from connecting to server via ssh. When I rerun playbook with this role for second time I get unreachable error (which is ok, ...
0
votes
0answers
26 views

how to do a successful exit from the playbook task

I have a playbook which is repeating one task, shell is invoked from ansible task, but it does not exit successful on completion of task and repeating the shell instructions again. Playbook: --- ...
1
vote
1answer
69 views

What is the reason of this error in ansible 2.7.10 - “ERROR! playbook entries must be either a valid play or an include statement|”

I am watching a tutorial of Ansible where I have to deploy a playbook. The play-book code are following: - name:"Do a demo" hosts:groupA tasks:!!seq - name:demo task 1 debug:!!seq ...
1
vote
1answer
49 views

Overwrite ansible executable in playbook

I'm wondering if it is possible to overwrite the executable value set in your ansible.cfg file within a playbook. Something like below... --- - name: 'New Server Setup' hosts: 'all' gather_facts: ...
0
votes
0answers
25 views

how to pass “physical path credentials to win_iis_webapplication” command in Ansible to create a web application and setting credentials

I am trying to create the Webapplication using Ansible with the win_iis_webapplication command. I am unable to set the "physical path credentials" for the site using this command. Could someone help ...
1
vote
2answers
92 views

Ansible not overriding default vars

I have the following variables defined in role/defaults/main.yml: jvm_heap_size_max: 1024 jvm_heap_size_min: "{{ (jvm_heap_size_max * 0.5)|int|abs }}" My group_vars folder looks like this: ├── ...
0
votes
1answer
219 views

Lookup secrets from AWS secret manager | Ansible

Using Terraform code I have created Other type of secrets in AWS Secrets Manager. I need to use these AWS secrets in Ansible code. I found this below link but I am unable to proceed it. https://docs....
0
votes
0answers
72 views

Trying to ping windows host uing ansible, but not successfull

I am trying to ping windows host from using ansible, but unable to ping. getting below errors: fatal: [localhost]: FAILED! => { "changed": false, "module_stderr": "#< CLIXML\r\n<...
0
votes
2answers
23 views

Script needs to be run as root error after already using become, become_user, and become_method

Writing a task to run an install script and normally it would have to be run with : sudo ./install.sh My task looks like: - name: Run the installer shell: "{{ tempdir_output.path }}/...
0
votes
1answer
184 views

How to use log_plays to generate a log file for playbook execution in Ansible

I am running Playbook to install in-house software on Windows target machines. I am printing a log of "msg" during this process so that I can forward that to QA / compliance team. However, I do not ...
0
votes
1answer
27 views

How to keep session alive while running the playbook for longer period of time?

I am running ansible playbook to restart some of our servers but we need to sleep for 40 minutes between each server restart so if I sleep for 40 minutes in my playbook then it sleeps for a while but ...