Is there a way to create different repository based on a condition in the same task in Ansible playbook?

Advertisements I am trying to shorten the number of tasks I have in my playbook. I am creating a yum repository on Linux hosts and adding a different baseurl depending on the OS version. It looks like this: vars: my_version: "{{ hostvars[inventory_hostname].ansible_distribution | int }}" – name: create mcrepo yum repo yum_repository: name: mcrepo description:… Read More Is there a way to create different repository based on a condition in the same task in Ansible playbook?

How to register archive file name as variable in Ansible?

Advertisements FYI: This is Ansible 2.7 I’m archiving a directory, and I need to grab the file name I create and register it as a variable for further use in the playbook. – name: Compress directory /etc/apache2/ into /tmp archive: path: /etc/apache2 dest: /tmp/{{ ansible_hostname }}-apache2-{{ ansible_date_time.date }}.tar.gz register: archive_name This gives me a file… Read More How to register archive file name as variable in Ansible?