Ansible task executed if file not exists condition

In this post, I will share an ansible task that is executed only if a condition is matched, the condition here is to check if file NOT exists on the system. — – name: run the playbook tasks on the localhost hosts: 127.0.0.1 connection: local become: yes vars: vhost_domain: “wpdemo.com” tasks: – name: ensure aptitude is…

Ansible structure layout – the best approach

This is called Ansible structure layout – the best approach that we used to use it as a template for our projects. This may be not the best but you can customized it as to fit your own. Directory Layout The top level of the directory would contain files and directories like so: production.in #…

Ansible template module for wordpress nginx vhost

In this post, I will share a simple playbook that run on localhost to demonstrate ansible template module with  nginx vhost for WordPress. playbook-wp-vhost.yml — – name: run the playbook tasks on the localhost hosts: 127.0.0.1 connection: local become: yes vars: vhost_domain: “test.com” tasks: – name: ensure aptitude is installed command: echo “Hello World” – name: Nginx…

Ansible Ad-hoc Commands

Ansible ad-hoc commands will do a quick task but do not want to save that command for later. In below commands “-a” indicates the ad-hoc command. To see the list of nodes from the master ad-hoc commands. #ansible ubnt –m command –a ls/ To create a demo file in node2 from the server using ad-hoc…

Beginning Ansible in 5 Minutes

Let’s beginning ansible by understanding  the basics of Ansible in our tutorial, how to install and understand Inventories, Playbook, Roles, Tasks. A how-to to get started in 5 minutes. So let me show you how easy it is to get started with Ansible. Install Let’s assume you’ll use pip to get this done : $ sudo easy_install…

How to work with Ansible loop

Ansible loop provides a lot of methods to repeat certain tasks until a condition is met. A basic example which can be used to install a lot of Linux packages can be written like the below example. – name: Ansible Loop example apt: name: “{{ item }}” state: present with_items: – python3 – ca-certificates -…