Server Setup

Ansible Tricks

by , , revisited on

We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish, and lots of useful modules for them, this is your one-stop repository to get all performance-related software.
You have to maintain an active subscription in order to be able to use the repository!

Ansible is something I really love to use. It makes server setups a breeze, provided you know how to code a decent playbook.

I present you with an always up-to-date list of Ansible tricks. Learn how to easily achieve tasks which are not available using standard modules.

Ensure directory is empty

Make an empty directory on your ansible host and synchronize it to remote dir:

- name: Empty remote directory
    src: empty/
    dest: "{{ remote_dir }}/"
    delete: yes
    recursive: yes

Credit: Original post

Ensure file is empty

- name: "ensure empty log file exists (important for fail2ban)"
    content: ""
    dest: /var/log/example.log
    force: yes
    owner: root
    group: root
    mode: 0600

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.