I wrote a playbook which clones from git three repo's and compiling them from source.
Whenever I provision a machine which uses this playbook, the repos are cloned, no matter if the local copy of the repo is already updated.
I'd like the git clone to happen only the first time and in the rest of the times when I run the playbook, I want Ansible to skip this step.
I've read about "local facts" on the Ansible docs but I'm having a hard time to understand how it should be implemented.
This is the playbook I wrote:
---
- name: Install required packages
apt: name={{item}} state=installed
with_items:
- "librdkafka-dev"
- "libyajl-dev"
- "librdkafka1"
- "cmake"
sudo: yes
tags: kafkacat
- name: Git clone kafkacat
git: repo=git://github.com/company/kafkacat.git
dest={{ kafkacat_installdir }} accept_hostkey=yes force=yes
tags: kafkacat
- name: Git clone librdkafka
git: repo=git://github.com/company/librdkafka.git
dest={{ kafkacat_installdir }}/librdkafka force=yes version={{ librdkafka_git_version }}
tags: kafkacat
- name: Git clone yajl
git: repo=git://github.com/company/yajl
dest={{ kafkacat_installdir }}/yajl force=yes version={{ yajl_git_version }}
tags: kafkacat
- name: librdkafka compilation (configure)
command: chdir={{ kafkacat_installdir }}/librdkafka {{ kafkacat_installdir }}/librdkafka/configure
tags: kafkacat
- name: librdkafka compilation (make)
command: chdir={{ kafkacat_installdir }}/librdkafka make
tags: kafkacat
- name: librdkafka compilation (make install)
command: chdir={{ kafkacat_installdir }}/librdkafka make DESTDIR={{ kafkacat_installdir }}/tmp-bootstrap install
tags: kafkacat
- name: yajl compilation (configure)
command: chdir={{ kafkacat_installdir }}/yajl {{ kafkacat_installdir }}/yajl/configure
tags: kafkacat
- name: yajl compilation (make)
command: chdir={{ kafkacat_installdir }}/yajl make
tags: kafkacat
- name: yajl compilation (make install)
command: chdir={{ kafkacat_installdir }}/yajl make DESTDIR={{ kafkacat_installdir }}/tmp-bootstrap install
tags: kafkacat
- name: Set vagrant user & group as the owner of the folder
file: path={{ kafkacat_installdir }} owner={{ kafkacat_owner }} group={{ kafkacat_group }} state=directory recurse=yes
sudo: yes
tags: kafkacat
- name: kafkacat compilation (configure)
command: chdir={{ kafkacat_installdir }} {{ kafkacat_installdir }}/configure --enable-json --enable-static
environment: env
tags: kafkacat
#- debug: var=env
- name: kafkacat compilation (make)
command: chdir={{ kafkacat_installdir }} make
environment: env
tags: kafkacat
#- debug: var=env
- name: kafkacat compilation (make install)
command: chdir={{ kafkacat_installdir }} make install
sudo: yes
tags: kafkacat
Your help is much appreciated.