From d4525cdb07b4d30d3efc01c03e8cfc08c84721c9 Mon Sep 17 00:00:00 2001 From: Cedric Girard Date: Wed, 1 Aug 2018 15:25:44 +0200 Subject: [PATCH] 6th exercise: use facts --- 60.Facts/60.Facts.md | 11 +++++++++++ 60.Facts/solution/solution.yml | 10 ++++++++++ 60.Facts/solution/template/motd.j2 | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 60.Facts/60.Facts.md create mode 100644 60.Facts/solution/solution.yml create mode 100644 60.Facts/solution/template/motd.j2 diff --git a/60.Facts/60.Facts.md b/60.Facts/60.Facts.md new file mode 100644 index 0000000..f02651d --- /dev/null +++ b/60.Facts/60.Facts.md @@ -0,0 +1,11 @@ +# 60 - Facts + +This exercise makes you use facts to adapt content + +## Playbook modification +Improve the playbook you created in the previous step to use the FQDN (*Fully Qualified Domain Name*) gathered as a fact instead of the inventory hostname. + +## Validation +Run the playbook and then try to connect to each host to validate you see the customized banner on ssh connection. + +There is a working playbook in `solution/solution.yml` diff --git a/60.Facts/solution/solution.yml b/60.Facts/solution/solution.yml new file mode 100644 index 0000000..da455c9 --- /dev/null +++ b/60.Facts/solution/solution.yml @@ -0,0 +1,10 @@ +- hosts: lab + gather_facts: true + tasks: + - name: Deploy MOTD + template: + src: template/motd.j2 + dest: /etc/motd + become: true + +# vim: set ft=yaml sw=2 et: diff --git a/60.Facts/solution/template/motd.j2 b/60.Facts/solution/template/motd.j2 new file mode 100644 index 0000000..7b5250c --- /dev/null +++ b/60.Facts/solution/template/motd.j2 @@ -0,0 +1,5 @@ +/----------------------------- +Welcome to the ansible managed host: {{ ansible_fqdn }} + +Please use Ansible playbooks instead of doing manual modifications on the system. +-----------------------------/