4.4 Ansible-Pull
In this lab we’ll have a short glimpse at how ansible-pull works.
Task 1
- Search 
docs.ansible.comfor information about the ansible-pull command. - Look for a way to execute a playbook using ansible-pull
 - Search for an example playbook
 
Solution Task 1
Task 2
On node1:
- Install all needed packages to use ansible-pull
 - Use an 
ansible-pullcommand that uses the resources in the folderresources/ansible-pull/of our GitHub repository located athttps://github.com/puzzle/ansible-techlab. This command should do the following:- Apply the playbook 
local.ymllocated at theresource/ansible-pullfolder and run it on all hosts in the inventory filehosts - Show the content of 
/etc/motdand verify, that the file was copied using ansible-pull - Also verify, that no content of the git repository was copied to the local folder.
 
 - Apply the playbook 
 
Tip
Note the following:
- If no playbook is specified, ansible-pull looks for a playbook 
local.yml. - The location of files given as parameters to the ansible-pull command are always relative to the top level of the git repository.
 - All information to run the ansible-pull command is taken from the git repository (playbook, inventory, MOTD-file to be copied). No local configuration is used!
 
Solution Task 2
 |  | 
Task 3
It’s a best practice to use cronjobs to trigger ansible-pull run at a regular basis. Do the following on node1:
- Create a cronjob 
/etc/cron.d/ansible-pull. This cronjob should run every minute as user ansible the ansible-pull command from Task 2. - Now remove the existing 
/etc/motdfile and use the commandwatchto show the content of/etc/motdevery second. We want to observe that our cronjob runs theansible-pullcommand again and restore the previously deleted MOTD-file. 
Solution Task 3
 |  | 
Task 4
This task has nothing to do with ansible-pull, we just clean up the ansible-pull configurations.
Create a playbook revert_motd.yml that runs on node1. It should:
- uninstall ansible
 - remove the cronjob 
/etc/cron.d/ansible-pull - empty the file 
/etc/motd 
Run the playbook.
Solution Task 4
 |  | 
All done?
Last modified September 26, 2025: Update dependency husky to v9 (#248) (71c506c)