{"id":27885819,"url":"https://github.com/epomatti/ansible-pull-demo","last_synced_at":"2026-04-20T10:04:04.956Z","repository":{"id":290228733,"uuid":"926330580","full_name":"epomatti/ansible-pull-demo","owner":"epomatti","description":"Setting up an ansible-pull managed node","archived":false,"fork":false,"pushed_at":"2025-04-27T17:08:34.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-27T18:23:09.678Z","etag":null,"topics":["ansible","ansible-pull","compose","cron","cronjob","crontab","docker","docker-compose","vagrant","virtualbox"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epomatti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-03T03:45:20.000Z","updated_at":"2025-04-27T17:08:38.000Z","dependencies_parsed_at":"2025-04-27T18:23:16.024Z","dependency_job_id":"02b0f57f-01db-417a-8cf6-043fc6ea22dd","html_url":"https://github.com/epomatti/ansible-pull-demo","commit_stats":null,"previous_names":["epomatti/ansible-pull-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fansible-pull-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fansible-pull-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fansible-pull-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fansible-pull-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epomatti","download_url":"https://codeload.github.com/epomatti/ansible-pull-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252462790,"owners_count":21751757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-pull","compose","cron","cronjob","crontab","docker","docker-compose","vagrant","virtualbox"],"created_at":"2025-05-05T07:47:07.134Z","updated_at":"2026-04-20T10:04:04.949Z","avatar_url":"https://github.com/epomatti.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `ansible-pull` demo\n\n## Local Development\n\nSetting up the local development environment to work with Ansible.\n\nYou'll need `virtualenv`:\n\n```sh\nsudo apt-get install python3-virtualenv -y\n```\n\nStart the environment:\n\n```sh\npython3 -m venv .venv\nvirtualenv .venv\nsource .venv/bin/activate\n```\n\nInstall the dependencies:\n\n```sh\npython3 -m pip install --upgrade pip\npython3 -m pip install -r requirements.txt\n```\n\n## Control Node\n\nDepending on yor preference, the following provisioning options are available in this repository.\n\n### Multipass\n\nLaunch the instance:\n\n```ps1\nmultipass launch 24.04 `\n  --name vm-ansible `\n  --cpus 4 `\n  --memory 8G `\n  --disk 50G `\n  --timeout 1800 `\n  --cloud-init .\\multipass\\cloud-init.yaml\n```\n\nConnect via SSH:\n\n```ps1\nmultipass shell vm-ansible\n```\n\nCheck if `*** System restart required ***`. If so, `sudo reboot`.\n\nVerify the cloud-init status:\n\n```sh\ncloud-init status\n```\n\nCheck logs if necessary:\n\n```sh\n/var/log/cloud-init-output.log\n/var/log/cloud-init.log\n```\n\n### VirtualBox\n\nPrepare the directory with Vagrant:\n\n```sh\nmkdir -p vagrant-pull-node/ansible\ncd vagrant-pull-node/ansible\nvagrant init \"ubuntu/jammy64\"\n```\n\nSet additional parameters as in the [virtualbox/Vagrantfile](virtualbox/Vagrantfile). This will add the necessary packages.\n\nCreate and connect to the VM:\n\n```sh\nvagrant up\nvagrant ssh\n```\n\n### Docker\n\n\u003e [!TIP]\n\u003e In case of docker fetch errors, you may try `docker system prune -a`\n\nFor lightweight docker environment, set it up:\n\n```sh\ndocker compose build\ndocker compose up -d\ndocker compose exec workstation /bin/bash\n```\n\n## `ansible-pull`\n\nThis section is executed from within the control node.\n\n### Simple Pull Command\n\n\u003e [!TIP]\n\u003e A fork will be required to create tokens in the account\n\nConnect to the GitHub account and generate a [new token](https://github.com/settings/personal-access-tokens). Prefer a fine-grained token, where only `read-only` permissions to the `Contents` to the repository is required.\n\n\u003e [!NOTE]\n\u003e Preferring the `https` URL option to use GitHub tokens\n\nThe next `ansible-pull` command was adapted from [this page](https://medium.com/planetarynetworks/ansible-pull-with-private-github-repository-d147fdf6f60b).\n\nFor development purposes, create a `/opt/ansible/pull.sh` script:\n\n\u003e [!TIP]\n\u003e Create link for `ln -s /opt/ansible/pull.sh /home/vagrant/pull.sh`\n\n```sh\n#!/bin/bash\ntoken=1234\nurl=\"https://$token:x-oauth-basic@github.com/epomatti/ansible-pull-demo.git\"\nansible-pull -U $url -d /opt/epomatti/ansible-pull-demo\n```\n\nExecute the Ansible pull script:\n\n```sh\nbash pull.sh\n```\n\n### Crontab\n\nThe [local.yml](local.yml) file will create a cron job to pull new configuration every minute. The package [flock](https://manpages.ubuntu.com/manpages/jammy/man1/flock.1.html) will be used to prevent cron job overlap.\n\nCheck the crontab logs:\n\n```sh\nsudo tail -f /var/log/syslog\n```\n\nThe script output will be redirected to this file:\n\n```sh\nsudo tail -f /var/log/ansible-pull.log\n```\n\nTo make ad-hoc adjustments to the local configuration:\n\n```sh\nsudo systemctl stop cron\n```\n\n## Ansible Vault\n\nCreate the key file, and add a secure password:\n\n```sh\ntouch ~/.vault_key\nchmod 600 ~/.vault_key\n```\n\nEncrypt files (they must be commited to the repository):\n\n```sh\nansible-vault encrypt --vault-password-file ~/.vault_key secret.txt\n```\n\nDecrypt the files locally:\n\n```sh\nansible-vault decrypt --vault-password-file ~/.vault_key secret.txt\n```\n\nWhen pulling, use the key:\n\n```sh\nansibel pull --vault-password-file\n```\n\n## Testing\n\n\u003e [!TIP]\n\u003e This is about [test strategies][test_strategies] for testing the application you are deploying\n\nThe primary tool for this should be [Molecule][molecule].\n\n```sh\nbash local.sh\n```\n\nRunning the tests:\n\n```sh\nbash tests.sh\n```\n\n## Reference Content\n\n- [Using Ansible \"Pull\" Mode to Dynamically Automate Server/Workstation Builds](https://youtu.be/sn1HQq_GFNE)\n- [Getting started with Ansible 01 - Introduction](https://youtu.be/3RiVKs8GHYQ?list=PLT98CRl2KxKEUHie1m24-wkyHpEsa4Y70)\n- [Using Ansible to automate your Laptop and Desktop configs!](https://youtu.be/gIDywsGBqf4)\n- [Encrypting Files with Ansible Vault](https://youtu.be/xeBnAbmt3Wk)\n\n[test_strategies]: https://docs.ansible.com/projects/ansible/latest/reference_appendices/test_strategies.html\n[molecule]: https://docs.ansible.com/projects/molecule/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Fansible-pull-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepomatti%2Fansible-pull-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Fansible-pull-demo/lists"}