Questions tagged [ansible-playbook]

468 questions
2
votes
1 answer

How to perform an action when a file is not present with Ansible?

I want to make a list of servers that don't have a particular file. I made the following Ansible playbook: - name: "If file not in /apps" hosts: all tasks: - name: Find apps find: paths: /apps/ patterns: "*" …
yes
  • 31
  • 1
  • 6
2
votes
3 answers

Make a skipped task show as "OK"

I have some ansible tasks that are run in two parts. The first part sets a condition, and the second part uses when to conditionally execute. Pseudo-example: - name: check if installed command: (...) register: is_installed - name: run install…
jdm
  • 191
  • 1
  • 11
2
votes
2 answers

selected hosts in inventory based on subset of name in ansible

I'm fairly new to ansible so maybe this is easy to do. We have a large number of devices that have a consistent naming convention among different…
flyerhawk
  • 27
  • 3
2
votes
1 answer

Create multiple directories with mode and loop via ansible

I'm trying to play with loop and ask in a playbook to ansible creating multiple directories on a server with specific attributes : mode owner group . I think i'm close but don't get it working. I get this error: Unsupported parameters for (file)…
proxyd43
  • 152
  • 1
  • 2
  • 12
2
votes
1 answer

Removing specific characters from a string on ansible

I have the following - set_fact: test_result: " {{ htmlres.content | regex_search('http://website([0-9]+)', '\\1') }}" Using debug, this returns the following " '[01]'" Wanting only the number, I did some experimenting using the replace()…
Ress
  • 45
  • 1
  • 2
  • 8
2
votes
2 answers

Ansible run certain tasks one one group of servers, other on another

I'm migrating a group of websites from one infrastructure to another, including a fairly slow rsync operation. The migration process includes changes to both the source and target systems. Due to a fairly slow rsync operation that is part of the…
jdog
  • 121
  • 7
  • 29
2
votes
2 answers

Dynamically creating a list in Ansible with jinja

I need to dynamically set a new list type variable list var. Here's a basic playbook example: vars: app_instances: - host_name: host1-domain inst_count: 3 - host_name: host2-domain inst_count: 1 - host_name:…
SergioLeone
  • 161
  • 1
  • 1
  • 5
2
votes
1 answer

How to merge two files into single file using ansible in remote server

I need to merge two files without duplicate entries in it. is there any way i can achieve it through ansible modules. Ex i have two files /etc/hosts1 and /etc/hosts2. I need to have one /etc/hosts file with all entries present in both /etc/hosts1…
celcoprab
  • 43
  • 2
  • 3
  • 8
2
votes
1 answer

How to rename a file using ansible

I need to rename hosts_example or hosts_Example to be named as hosts_real if any of the file exists - name: Playbook to Standardize Hosts hosts: test vars: destpath: /etc/hosts_real filename: [ /etc/hosts_example,/etc/hosts_Example ] …
celcoprab
  • 43
  • 2
  • 3
  • 8
2
votes
1 answer

Ansible on IOS to loop through subset of interfaces

Running WISL on Windows 10 and Ubuntu with ansible 2.9.9. I am new to Ansible. I execute a show on a Cisco device to yield the interfaces on which a given network protocol runs. I then want to extract the interfaces and execute commands on them. In…
IainT
  • 23
  • 4
2
votes
1 answer

How to install RPM Fusion repository with Ansible on Fedora 32 Server virtual machine?

I want to install RPM Fusion repository on Fedora 32 Server virtual machine with Ansible I've tried various possibility unsuccessfully : - name: Enable the RPM Fusion repository command: dnf install…
Maxime
  • 69
  • 7
2
votes
0 answers

RouterOS shell command result with Ansible is different?

You will see, I have a little problem with the execution of an Ansible task, since I am giving it the same command that I work with in the Mikrotik shell, but the result is a little different and I just don't understand why. You will see, I am…
2
votes
1 answer

Ansible apt module hangs, process sleeping

Ansible version: ansible 2.9.6 Remote servers: "Debian GNU/Linux 10 (buster)" Ansible module: apt I'm running a simple playbook on 2 debian 10 nodes. I install Debian 10 with an ansible playbook on both nodes. After that, I run the next role on a…
VictorMJ
  • 108
  • 1
  • 5
2
votes
1 answer

-bash: ansible-playbook: command not found

Fresh Fedora Server Netinstall. Updated. Installed only Git and Ansible latest versions from standard repo. Want to execute Ansible against it's own host (localhost) to set up its host itself (not using ansible-pull). Copied ssh-keys. Connected via…
Dzintars
  • 201
  • 1
  • 2
  • 7
1
vote
2 answers

Ansible playbook - variable concat in conditional

I have a working task to migrate (copy) a specific part of my homedir (second to last line is the important one): - name: "Migrate my-pc module home files" copy: src: "{{ migration_source_path }}{{ item }}" dest: "{{…
Carolus
  • 129
  • 1
  • 10