Questions tagged [ansible]

Ansible is an automation tool ("IT orchestration engine", per the company web site) for the deployment and configuration of applications and systems.

Filter by
Sorted by
Tagged with
0 votes
2 answers
46 views

Ansible - How to reboot the server based on condition?

I wrote the playbook to apply the security patches on Linux servers, the only part remaining is to write the task to restart the patched server. Below is the content of the task to apply the patches - ...
user avatar
  • 3,874
0 votes
0 answers
19 views

Failed ssh sttempt via Ansible

fatal: [SW1]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "paramiko: The ...
user avatar
1 vote
0 answers
23 views

How should I use session cookies with OVMM Rest API and Ansible URI Module

I am able to use the Oracle Virtual Machine Manager (OVMM) REST API successfully with the Ansible URI module with the exception that I have to pass the username and password to EACH call instead of ...
user avatar
0 votes
1 answer
25 views

Ansible - Prompt for User Input only for Specific host in a Group

I have a multiple environments adn i classified them in groups and each group have multiple hosts During execution of playbook i want user to enter the instruction so to do this i came across the ...
user avatar
  • 3,874
0 votes
0 answers
50 views

Ansible Undefined Variable

I am using ansible [core 2.11.10] and I recently made the following yaml file : - name: Linux Security Patching Playbook hosts: Linux_NPROD become: true become_user: root vars: ...
user avatar
-1 votes
0 answers
36 views

Using sed or Ansible to replace a line in a file containing special characters

I have a yaml file containing this line: \ - ifdown eth0\n - ifup eth0\n - sleep 4\n" I want to replace this line with this line: \ - ifdown eth0\n - ifup eth0\n - sleep 4\...
user avatar
0 votes
1 answer
22 views

Can I use "when" condition in defination (start of Playbook) section of Ansilbe playbook?

I'm writing a playbook and this is what I'm trying to achieve: Company has a banking application which has components spread on multiple servers. This service can be stopped from a single script or ...
user avatar
  • 3,874
1 vote
0 answers
219 views

CentOS 8.5.2111 with EPEL repository: Upgrading Ansible via dnf fails

I've installed ansible-2.9.27-1.el8.noarch on a CentOS Linux release 8.5.2111 machine. For this I've enabled the "epel-release" repo using "dnf install epel-release". When I try to ...
user avatar
0 votes
1 answer
23 views

Ansible: Better way of using set_fact

I use following playbook: ~ # cat play.yml - name: MAIN PLAY hosts: localhost gather_facts: no vars: status: check1: present check2: "" tasks: - debug: var:...
user avatar
0 votes
1 answer
48 views

Ansible find files only if contains particular string

I need a small help in writing an ansible playbook. I have written the below till now which is listing all files with config basically. but I need to filter out the files which are basically .git/...
user avatar
3 votes
1 answer
28 views

How can I dynamically construct a menu with ansible.builtin.pause module?

The goal here is to dynamically construct a menu from an available variable file In this example I use ansible.builtin.pause module but I'm not sure this is the best way variable file: vars.yml --- ...
user avatar
1 vote
1 answer
75 views

Run a shell command via tower-cli

Ansible CLI allows to run a custom shell command (done implicitly using the default module "ansible.builtin.command"): ansible myhost -a "/bin/mycommand" Is it possible to do the ...
user avatar
  • 25.8k
1 vote
2 answers
33 views

Ansible: Copy file on all the servers except on server which are not part of specific Group(2)

I have more than 200 servers on which i have to copy the Repo file and what i dont want is to copy the file on e.g AppCluster and DBCluster servers. Because Clusters have different Repo files and ...
user avatar
  • 3,874
0 votes
1 answer
98 views

Why does community.general.telegram (in Ansible) produce an error?

I want to configure an Ansible playbook, add some code for start a service and send a notification to Telegram but I am faced with the error shown below. I think this is not a typing error but some ...
user avatar
2 votes
1 answer
117 views

How to parse an escaped json string with ansible/jmespath/jq?

I'm using the Ansible module for Bluecat to make an authorized API call to get some information about a subnet. The response looks something like this: "result": { "changed"...
user avatar
0 votes
1 answer
33 views

ansible doesn't work anymore if I use "RequestTTY force" and "RemoteCommand" in my ssh config

So my ssh config looks like this: Host bastion Hostname 35.46.192.2 User bob2 RequestTTY force RemoteCommand ssh 35.45.96.47 So the idea is that I would like to ssh to my bastion, ...
user avatar
0 votes
1 answer
575 views

diffie-hellman-group1-sha1 key exchange on Ubuntu - Issues

I've been trying to setup Ansible to connect to some of our legacy production switches to take regular backups. I'm running into the issue that many have faced, for example here. I've created a file ~/...
user avatar
  • 3
1 vote
1 answer
65 views

Ansible: How to verify ansible_become_user, and if missing prompt for user input (multiple hosts)

I use multiple hosts and I want to prompt user to provide sudo username and password if ansible_become_user and ansible_become_password is not set in the inventory or playbook I use following: ...
user avatar
2 votes
1 answer
34 views

Ansible: Run new playbook from task

Let assume following: main-playbook.yml - name: Play-1 hosts: localhost connection: local gather_facts: no roles: - role: my-role vars: newhost: 192.168.1.1 ...
user avatar
1 vote
1 answer
177 views

Ansible convert dictionary to mix of dictionary/array

I use following files: variable file: db.yml x86_64: alpine: version: 3.15.0 debian: version: 11.3.0 aarch64: alpine: version: 3.15.0 debian: version: 11.3.0 playbook: ...
user avatar
2 votes
3 answers
47 views

How to pass argument to a for loop from a file and run in parallel, and create log for each argument

for test in "${a[@]}" do sh ansiblescript.sh -s $a if [[ $? -eq 0 ]]; then echo "Success" else echo "Failed" exit 1 fi done ...
user avatar
  • 21
0 votes
2 answers
69 views

Use Ansible 2.12 to access AWS EC2 via host: tag class

On my local hardware, I have a Vagrant box running Ubuntu 20, on which I'm using Ansible 2.12.2 I am able to access AWS and even create an EC2 instance within a VPN. When I view inventory, I can see ...
user avatar
0 votes
2 answers
33 views

Ansible include_task based on condition (directory empty or certifcate is expired or 30 days remaining in expiry)

I am using Ansible letsencrypt module to generate SSL certificates. The playbook is working fine, the certificate is generated and applied. Now I want that this task is only played when certain ...
user avatar
1 vote
2 answers
88 views

Ansible: why task is skipped when: var is true

From below examples Why DEBUG 2 has been skipped when db.x86_64.alpine.update is true I have been also trying "when: db.x86_64.alpine.update|bool is true" but this also fails Variable file ...
user avatar
1 vote
1 answer
50 views

Ansible: How to update directory value in the file

I use following: directory file: dir.yml x86_64: alpine: update: version: 3.14.0 aarch64: alpine: update: version: 3.14.0 ansible playbook: --- - name: Playbook hosts: ...
user avatar
0 votes
0 answers
51 views

Installing Openstack using kolla Ansible : Internal Server Error

I am installing Openstack (all-in-one) on a ubuntu 20.04 vm with 16GB Ram, 4 vCPUs and 40GB memory. I am following this tutorial. After all steps carried out succesfully, the last one for actual ...
user avatar
  • 117
1 vote
1 answer
55 views

Can I use something else than curly bracket in nftables.conf?

I am trying to template stateful nftables configuration file with Ansible. Ansible uses Jinja for templating and Jinja uses curly braces for variables: {{ variable }} Nftables configuration uses ...
user avatar
  • 23
0 votes
0 answers
161 views

How to login/authenticate web URL using ansible playbook with Username and password

I am pretty new to the Ansible playbook and I am trying to log in to the website URL using username and password. I am facing the issue. I am using below code snippet. it would be great if someone ...
user avatar
0 votes
1 answer
123 views

Create new user and delete current user 'ubuntu' with ansible-playbook

I want to automate some provisioning on raspberry pi or oracle cloud with Ansible. Those are tasks sequence: run the script with current/default/unsafe user 'ubuntu' ansible-playbook security.yml -u ...
user avatar
1 vote
2 answers
135 views

How to determine if Ubuntu system needs a reboot?

I recently applied a kernel patch (mix of debian 10 and Ubuntu 18.04) using ansible. I am trying to figure out a way to check if each machine being updated has been, or needs, a reboot. I've read that ...
user avatar
0 votes
2 answers
159 views

Ansible -m shell and find command

Does anybody know how to solve this problem? ansible -m shell -i test.txt -a "sudo find / -regex '.*\(tar\|zip\)$' -type f 2>/dev/null | while read i; do echo $i; done" The problem is ...
user avatar
  • 25
0 votes
1 answer
394 views

"msg": "|combine expects dictionaries, got AnsibleUndefined"

I have a problem to roll out my users role maybe someone can help me. I have the following Ansible role called "users" - name: Create required groups. become: yes group: ...
user avatar
  • 15
0 votes
1 answer
101 views

awx superuser creation automatically

I want to create awx super user automatically. i am using the command awx-manage createsuperuser --username <NAME> if i use this command, it prompt for email and 2 times password. is there any ...
user avatar
2 votes
1 answer
63 views

Use service_facts module to show the current version of the cron process?

I am learning Ansible from this book and it contains this lab: Write a playbook according to the following specifications: The cron module must be used to restart your managed servers at 2 a.m. each ...
user avatar
0 votes
0 answers
74 views

Checkers problem with syntastic vim plugin

I have carefully read the documentation, tried everything, but unfortunately I have not succeeded. I tried to enable Ansible and Python checkers, but something does not work. The strange thing is that ...
user avatar
0 votes
1 answer
141 views

Ansible - replace first occurrence of certain expression in file - path includes hostname

I need to replace the first occurrence of a certain string in a specific file. I think about to use the replace module of Ansible for this. - hosts: abc tasks: - name: Replace first occurence of ...
user avatar
  • 125
-1 votes
1 answer
140 views

Unable to Install mysql-server using dnf in Ansible on CentOS

I need to install mysql-server and the chosen method was using Ansible as it streamlines the process. But while installing it, I have been finding this issue which I have not been able to debug. My ...
user avatar
0 votes
2 answers
138 views

create partition using ansible

I need to run those commands, but I do not want to use 'shell', is there way to create home partition using ansible tools? lvcreate -L5G -n home vg0 mkdir /home mkfs.xfs /dev/mapper/vg0-home mount /...
user avatar
0 votes
1 answer
789 views

Need advice executing awk commands resulting from output of Ansible ad-hoc command

When I execute the following command to find index IDs by using an Ansible ad-hoc command: $ ansible oamvip -i /storage/inventory/None/${myvnf}hosts --become -m shell -a "/usr/sbin/aladmin list | ...
user avatar
  • 9
0 votes
1 answer
169 views

Ansible playbooks failing on RHEL8 with FIPS

I have two sets of Linux VMs in a GCP (Google cloud) environment: Debian9 and RHEL8. The RHEL8 environment is FIPS-140 enabled, due to security/compliance requirements. None of our Ansible playbooks ...
user avatar
1 vote
1 answer
220 views

Ansible: group_names variable expansion doesn't work

In ansible i created a sshd_config which will be copied on servers which are part of sit group [sit] 192.168.18.10 192.168.18.11 192.168.18.12 192.168.18.13 192.168.18.14 192.168.18.15 - name: Deploy ...
user avatar
  • 3,874
0 votes
0 answers
24 views

Run Ansible via Shell Command on Remote GCP Servers

I have 3 Linux servers A, B and C. A is where all the developers use, B is a Ansible server that has a playbook, C is the target server that I need to run some tasks. This is the frame of the playbook ...
user avatar
1 vote
2 answers
228 views

Linux, add to sudoers file programmatically

What is the correct way to update the sudoers file programmatically? Specifically: How can I add ,timestamp_timeout=600 to the end of the Defaults env_reset line in my sudoers files (to increase the ...
user avatar
  • 569
0 votes
0 answers
743 views

Ansible - looping over all items in a list inside a dictionary

I'm using Ansible to find files on Windows machines using the win_find module. I'd like to do this in 2 steps: Find any directory in a given location (ex: find all directories under C:/ Search each ...
user avatar
  • 77
0 votes
0 answers
88 views

Ansible Tower 403 Forbidden Error: when trying to create a job template

I am new to ansible tower and for my requirement, I need to perform REST API calls(GET, POST) to create and retrieve resources in Ansible Tower. I am able to make POST actions for all resources(...
user avatar
  • 11
1 vote
0 answers
45 views

IP forwarding not working on Vagrant + Ansible scenario

This is the scenario It is created with Vagrant and configured with Ansible, but the specific problem I'm going to ask about here is why IP forwarding is not working when it should be working. On the ...
user avatar
0 votes
0 answers
67 views

I can't configure persistent default routes on debian VMs with Ansible and Vagrant

My scenario is the following Those 2 VMs are automatically created with Vagrant, and then configured with Ansible. For the moment, I've been able to delete and add the desired default route with the ...
user avatar
0 votes
1 answer
140 views

Ansible-Galaxy install from tarball stuck on establishing connection to galaxy.ansible.com

I'm trying to install an ansible collection via ansible-galaxy. However, the programm is stuck during the step Initial connection to galaxy_server: https://galaxy.ansible.com and I have no idea what ...
user avatar
  • 107
0 votes
1 answer
37 views

Most Stable/efficient method for OpenStack Deployment using Debain

I was wondering witch method to use for deploy openstack I read guides of openstack but there is no focusing on Debian. so what it's most stable method to deploy openstack on Debian? Thanks
user avatar
  • 101
0 votes
1 answer
71 views

Working with files in Ansible inventory

This feels like it should be a really easy thing to do, but I cannot figure it out. I am aware of several pieces of documentation outlining where Ansible is looking for files by default and most of ...
user avatar
  • 633

1
2 3 4 5
9