How can I add a PPA repository using Ansible?

I'm trying to add a new repository to a server so that I can install Java by Ansible. Unfortunately whenever I try to run the playbook it fails because of a GPG error. Can somebody explain what is...

Running Python script via ansible

I'm trying to run a python script from an ansible script. I would think this would be an easy thing to do, but I can't figure it out. I've got a project structure like this: playbook-folder ...

Jinja2 filter list using string contains test

I'm trying to filter a list in ansible in Jinja2 when the elements contain a string, but the Jinja documentation doesn't seem clear enough for me to figure it out. This is what I have so far: -...

Execute curl -X with ansible playbook

I want to execute the next command using ansible playbook: curl -X POST [email protected] -H "Content-Type: application/json" http://marathon.service.consul:8080/v2/apps How can I run it? If...

How to do Ansible conditional include_vars?

I am trying to use include_vars based on when condition as follows: - include_vars: clouderamanager.yml when: '{{ inventory_hostname }}' in groups['hadoop-clouderamanager'] - include_vars:...

How to change an existing user's password?

I'm trying to change the password of an existing user with Ansible, but only if the user is already present. I do not want to create any new users. Is there any good way? vars: myusers: - {...

ansible play_hosts template loop

I'm trying to use the play_hosts variable in an ansible template. I'm trying to setup a master / slave domain setup for wildfly. So I wish to loop over all hosts in the inventory group, without...

getting "skipping: no hosts matched" with ansible playbook

my below ansible (2.1.1.0) playbook is throwing "skipping: no hosts matched" error when playing for host [ec2-test]. The ansible hosts file has the fqdn of the newly created instance added. It...

How to add spaces at beginning of block in Ansible's blockinfile?

I found this blockinfile issue, where a user suggested adding a number after the "|" in the "block: |" line, but gives a syntax error. Basically, I want to use blockinfile module to add a block of...

Ansible How to copy the content to file with user input

I am just trying to write ansible-playbook where I have to give an input to the file content. For Example Enter the File Lists 7124 /var/www/A.txt 7125 /var/www/B.txt This has to update on file...

So I am trying to get a database up and running with php artisan for Laravel 5.x but I get this error when I check to see if I have mysql running

zsh: command not found: mysql I have exhausted the SO forums that provide suggestions and nothing is working and most talk about bash_profile, but this is an issue in my zsh environment. Please...

How to change ansible verbosity level without changing the command line arguments?

I want to control the verbosity of ansible playbooks using an environment variable or a global configuration item. This is because ansible is called from multiple places in multiple ways and I...

Ansible: To use the 'ssh' connection type with passwords, you must install the sshpass program"

Recently I created new roles called spd in my existing project. While other script works fine in the setup. This newly created fails. Please point me to what is going wrong here ansible/roles ...

Ansible - wait for user to key in value for interactive scripts on remote machine

I would like the ansible to wait for my input in the command line for interactive script running in remote machine. "Expect" will not suite my requirement as the interactive questions keep...

Ansible stdout Formatting

Assuming the below tasks: shell: "some_script.sh" register: "some_script_result" debug: msg: "Output: {{ some_script_result.stdout_lines }} I receive the below output: "msg": "Output:...

Ansible - pip not found

I am getting this error: TASK [pip] ********************************************************************* failed: [default] (item=urllib3) => {"changed": false, "item": "urllib3", "msg":...

How do I configure Ansible to jump through two bastion hosts?

I want to write an Ansible playbook (using Ansible 2.7.5) that will jump through two hosts before reaching the intended server to do things such as install docker and python, etc. I'm able to get...

How to resolve "could not locate file in lookup" reading id_rsa.pub?

in an Ansible playbook, I'm trying to read the default public key into a variable to be used later. Here's my yml: - hosts: hostsGroup become: false vars: publicKey: "{{ lookup('file',...

Is there an option on Ansible for getting squid service status?

I'm setting up a new playbook, and want to support both service status and systemctl status. I want to monitor a service called Squid on Ubuntu 14.04 that has only service and 16.04 that has both...

Timeout waiting for privilege escalation prompt

Context I'm asking this question because those two questions/answerse (one and two) have little context, and I'd liket o expand on it. I'm trying to provision CentOS7 production servers with...

Docker container - How to set GID of socket file to groupID 130?

This is docker in docker scenario. Below is the corresponding code in Dockerfile that has docker client installed: FROM jenkins/jenkins:2.190.2 ENV DEBIAN_FRONTEND=noninteractive # Official...

Ansible search for a substring in stdout output

Team, I am trying to match a version and that fails when whole string does not match. so I just want to match first two octects. I tried several combons but no luck. - name: "Validate k8s...

`remote_user` is ignored in playbooks and roles

I have defined the following in my ansible.cfg # default user to use for playbooks if user is not specified # (/usr/bin/ansible will use current user as default) remote_user = ansible However I...

How do I get my ansible playbook to gather the desired AWS EC2 information and wrap properly in a text output file?

I have an ansible playbook pretty much written out, including output to a file. I have the few fields that I want to gather from my EC2 environment (simply tag:Name; Public IP, Private IP). I'm...

ansible returns with "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

I am running myserver in ubuntu: + sudo cat /etc/os-release NAME="Ubuntu" VERSION="16.04.6 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.6...

How to change vmware network adapter with ansible

Im using ansible 2.9.2, i need to replace network adapter on vmware specific vm. In my vcenter vm settings i see : Networks: Vlan_12 My playbook doesnt see that network name. tasks: -...

How does copy work after sftp and scp fails?

I have a problem with a copy task from the remote server onto my local host. I get the following errors [WARNING]: sftp transfer mechanism failed on [ip addr]. Use ANSIBLE_DEBUG=1 to see detailed...

Ansible With_Together loop iteration

I am stuck on a task where I am trying to use with_together and loop through multiple lists. Here is the scenario:- I have two sets of data: "node_list": [ "10.2.0.1",...

Tower: What is causing "[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details"

I am just starting to work with Ansible Tower and made a project and then a job template under that project that uses a small initial test playbook (Test.yml): --- - hosts: east01.xxxxx.com ...

ansible playbook error was: ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' although the module is installed

After upgrading ansible to version 2.10.5 and python3.8.10 my playbook.yml fails with this error. ModuleNotFoundError: No module named 'azure.mgmt.monitor.version' fatal: [localhost]: FAILED! =>...