{"id":13572533,"url":"https://github.com/leucos/ansible-tuto","last_synced_at":"2025-04-13T22:30:01.050Z","repository":{"id":7288688,"uuid":"8603940","full_name":"leucos/ansible-tuto","owner":"leucos","description":"Ansible tutorial","archived":false,"fork":false,"pushed_at":"2023-09-20T06:17:25.000Z","size":345,"stargazers_count":2269,"open_issues_count":9,"forks_count":697,"subscribers_count":109,"default_branch":"master","last_synced_at":"2025-04-06T19:08:54.751Z","etag":null,"topics":["ansible","tutorial","vagrant"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leucos.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}},"created_at":"2013-03-06T13:27:18.000Z","updated_at":"2025-04-03T16:23:33.000Z","dependencies_parsed_at":"2024-01-09T19:01:09.684Z","dependency_job_id":"c55de4c0-05b4-4c2b-97cb-ea8b8bf792cd","html_url":"https://github.com/leucos/ansible-tuto","commit_stats":{"total_commits":235,"total_committers":48,"mean_commits":4.895833333333333,"dds":0.5659574468085107,"last_synced_commit":"676f00c0e152469b647f57f610ce3942e1885387"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leucos%2Fansible-tuto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leucos%2Fansible-tuto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leucos%2Fansible-tuto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leucos%2Fansible-tuto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leucos","download_url":"https://codeload.github.com/leucos/ansible-tuto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790496,"owners_count":21162022,"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","tutorial","vagrant"],"created_at":"2024-08-01T14:01:26.161Z","updated_at":"2025-04-13T22:30:00.999Z","avatar_url":"https://github.com/leucos.png","language":"Shell","funding_links":[],"categories":["Shell","Tutorials","Playbooks","vagrant"],"sub_categories":[],"readme":"# Ansible tutorial\n\nThis tutorial presents Ansible step-by-step. You'll need to have a (virtual or\nphysical) machine to act as an Ansible node. A Vagrant environment is provided for \ngoing through this tutorial.\n\nAnsible is a configuration management software that lets you control and\nconfigure nodes from another machine. What makes it different from other\nmanagement software is that Ansible uses (potentially existing) SSH\ninfrastructure, while others (Chef, Puppet, ...) need a specific PKI\ninfrastructure to be set up.\n\nAnsible also emphasizes push mode, where configuration is pushed from a master\nmachine (a master machine is only a machine where you can SSH to nodes from) to\nnodes, while most other CM typically do it the other way around (nodes pull\ntheir config at times from a master machine).\n\nThis mode is really interesting since you do not need to have a 'publicly'\naccessible 'master' to be able to configure remote nodes: it's the nodes\nthat need to be accessible (we'll see later that 'hidden' nodes can pull their\nconfiguration too!), and most of the time they are.\n\nThis tutorial has been tested with **Ansible 2.9**.\n\nWe're also assuming you have a keypair in your ~/.ssh directory.\n\n## Quick start\n\n- install Vagrant if you don't have it\n- install ansible (preferably 2.10.5+ and using pip+virtualenv)\n- `vagrant up`\n- goto [step-00](./step-00/README.md)\n\n## Complete explanations\n\n### Installing Ansible\n\nThe reference is the [installation\nguide](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html),\nbut I strongly recommend the [Using pip \u0026 virtualenv (higly recommended\n!)](#using-pip--virtualenv-higly-recommended-) method.\n\n#### Using pip \u0026 virtualenv (higly recommended !)\n\nThe best way to install Ansible (by far) is to use `pip` and virtual\nenvironments.\n\nUsing virtualenv will let you have multiple Ansible versions\ninstalled side by side, and test upgrades or use different versions in\ndifferent projects. Also, by using a virtualenv, you won't pollute your\nsystem's python installation.\n\nCheck\n[virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)\nfor this. It makes managing virtualenvs very easy.\n\nUnder Ubuntu, installing virtualenv \u0026 virtualenvwrapper can be done like\nso:\n\n```bash\nsudo apt install python3-virtualenv virtualenvwrapper python3-pip\nexec $SHELL\n```\n\nYou can then create a virtualenv:\n\n```bash\nmkvirtualenv ansible-tuto\nworkon ansible-tuto\n```\n\n(`mkvirtualenv` usually switches you automatically to your newly created\nvirtualenv, so here `workon ansible-tuto` is not strictly necessary, but\nlets be safe).\n\nThen, install ansible via `pip`:\n\n```bash\npip install ansible==2.7.1\n```\n\n(or use whatever version you want).\n\nWhen you're done, you can deactivate your virtualenv to return to your\nsystem's python settings \u0026 modules:\n\n```bash\ndeactivate\n```\n\nIf you later want to return to your virtualenv:\n\n```bash\nworkon ansible-tuto\n```\n\nUse `lsvirtualenv` to list all your virtual environments.\n\n#### From source (if you want to hack on ansible source code)\n\nAnsible devel branch is always usable, so we'll run straight from a git checkout.\nYou might need to install git for this (`sudo apt-get install git` on Debian/Ubuntu).\n\n```bash\ngit clone git://github.com/ansible/ansible.git\ncd ./ansible\n```\n\nAt this point, we can load the Ansible environment:\n\n```bash\nsource ./hacking/env-setup\n```\n\n#### From a distribution package (discouraged)\n\n```bash\nsudo apt-get install ansible\n```\n\n#### From a built deb package (discouraged)\n\nWhen running from an distribution package, this is absolutely not\nnecessary. If you prefer running from an up to date Debian package,\nAnsible provides a `make target` to build it. You need a few packages to\nbuild the deb and\nfew dependencies:\n\n```bash\nsudo apt-get install make fakeroot cdbs python-support python-yaml python-jinja2 python-paramiko python-crypto python-pip\ngit clone git://github.com/ansible/ansible.git\ncd ./ansible\nmake deb\nsudo dpkg -i ../ansible_x.y_all.deb (version may vary)\n```\n\n### Cloning the tutorial\n\n```bash\ngit clone https://github.com/leucos/ansible-tuto.git\ncd ansible-tuto\n```\n\n### Running the tutorials interactively with Docker\n\nYou can run the tutorials here interactively including a very simple setup with docker.\n\nCheck [this repository](https://github.com/turkenh/ansible-interactive-tutorial) for details.\n\n### Using Vagrant with the tutorial\n\nIt's highly recommended to use Vagrant to follow this tutorial. If you don't have \nit already, setting up should be quite easy and is described in [step-00/README.md](https://github.com/leucos/ansible-tuto/tree/master/step-00/README.md).\n\nIf you wish to proceed without Vagrant (not recommended!), go straight to\n[step-01/README.md](https://github.com/leucos/ansible-tuto/tree/master/step-01).\n\n## Contents\n\n[Terminology](https://docs.ansible.com/ansible/glossary.html):\n - [command or\n   action](https://docs.ansible.com/ansible/intro_adhoc.html): [ansible module](https://docs.ansible.com/ansible/modules.html) executed in\n   stand-alone mode. Intro in [step-02](https://github.com/leucos/ansible-tuto/tree/master/step-02).\n - task: combines an action (a module and its arguments) with a name\n   and optionally some other keywords (like looping directives).\n - play: a yaml structure executing a list of roles or tasks over a list\n   of hosts\n - [playbook](https://docs.ansible.com/ansible/playbooks_intro.html):\n   yaml file containing multiple plays. Intro in\n   [step-04](https://github.com/leucos/ansible-tuto/tree/master/step-04).\n - [role](https://docs.ansible.com/ansible/playbooks_roles.html): an\n   organisational unit grouping tasks together in order to achieve\n   something (install a piece of software for instance). Intro in\n   [step-12](https://github.com/leucos/ansible-tuto/tree/master/step-12).\n\nJust in case you want to skip to a specific step, here is a topic table of contents.\n\n- [00. Vagrant Setup](https://github.com/leucos/ansible-tuto/tree/master/step-00)\n- [01. Basic inventory](https://github.com/leucos/ansible-tuto/tree/master/step-01)\n- [02. First modules and facts](https://github.com/leucos/ansible-tuto/tree/master/step-02)\n- [03. Groups and variables](https://github.com/leucos/ansible-tuto/tree/master/step-03)\n- [04. Playbooks](https://github.com/leucos/ansible-tuto/tree/master/step-04)\n- [05. Playbooks, pushing files on nodes](https://github.com/leucos/ansible-tuto/tree/master/step-05)\n- [06. Playbooks and failures](https://github.com/leucos/ansible-tuto/tree/master/step-06)\n- [07. Playbook conditionals](https://github.com/leucos/ansible-tuto/tree/master/step-07)\n- [08. Git module](https://github.com/leucos/ansible-tuto/tree/master/step-08)\n- [09. Extending to several hosts](https://github.com/leucos/ansible-tuto/tree/master/step-09)\n- [10. Templates](https://github.com/leucos/ansible-tuto/tree/master/step-10)\n- [11. Variables again](https://github.com/leucos/ansible-tuto/tree/master/step-11)\n- [12. Migrating to roles](https://github.com/leucos/ansible-tuto/tree/master/step-12)\n- [13. Using tags (TBD)](https://github.com/leucos/ansible-tuto/tree/master/step-13)\n- [14. Roles dependencies (TBD)](https://github.com/leucos/ansible-tuto/tree/master/step-14)\n- [15. Debugging (TBD)](https://github.com/leucos/ansible-tuto/tree/master/step-15)\n- [99. The end](https://github.com/leucos/ansible-tuto/tree/master/step-99)\n\n## Contributing\n\nThanks to all people who have contributed to this tutorial:\n\n* [Aladin Jaermann](http://github.com/oxyrox)\n* [Alexis Gallagher](https://github.com/algal)\n* [Alice Ferrazzi](https://github.com/aliceinwire)\n* [Alice Pote](https://github.com/aliceriot)\n* [Amit Jakubowicz](https://github.com/amitit)\n* [Anonymous Contributor](https://github.com/terroirman)\n* [Arbab Nazar](https://github.com/arbabnazar)\n* [Atilla Mas](https://github.com/atillamas)\n* [Ben Visser](https://github.com/noqcks)\n* [Benny Wong](https://github.com/bdotdub)\n* [Bernardo Vale](https://github.com/bernardoVale)\n* [Chris Schmitz](https://github.com/ccschmitz)\n* [Cyril Mouchel](https://github.com/mouchh)\n* [dalton](https://github.com/dalton)\n* [Daniel Howard](https://github.com/dannyman)\n* [David Golden](https://github.com/dagolden)\n* [Davide Restivo](https://github.com/daviderestivo)\n* [Eric Corson](https://github.com/frodopwns)\n* [Eugene Kalinin](https://github.com/ekalinin)\n* [Ludovic Gasc](https://github.com/GMLudo)\n* [Hartmut Goebel](https://github.com/htgoebel)\n* [Jelly Robot](https://github.com/jellyjellyrobot)\n* [Justin Garrison](https://github.com/rothgar)\n* [Karlo](https://github.com/karlo57)\n* [lenowac](https://github.com/lenowac)\n* [Marchenko Alexandr](https://github.com/mac2000)\n* [Maxim Zaitsev](http://github.com/7aitsev)\n* [Michael B. Sumulong](http://github.com/MSumulong/)\n* [Mikhail Shavliuk](https://github.com/mshavliuk)\n* [mxxcon](https://github.com/mxxcon)\n* [Patrick Pelletier](https://github.com/skinp)\n* [Pierre-Gilles Levallois](https://github.com/Pilooz)\n* [Ruud Kamphuis](https://github.com/ruudk)\n* [tkermode](https://github.com/tkermode)\n* [torenware](https://github.com/torenware)\n* [Victor Boivie](https://github.com/boivie)\n* [Yauheni Dakuka](https://github.com/ydakuka)\n\n(and sorry if I forgot anyone)\n\nI've been using Ansible almost since its birth, but I learned a lot in\nthe process of writing it. If you want to jump in, it's a great way to\nlearn, feel free to add your contributions.\n\nThe chapters being written live in the\n[writing](https://github.com/leucos/ansible-tuto/tree/writing) branch.\n\nIf you have ideas on topics that would require a chapter, please open a\nPR.\n\nI'm also open on pairing for writing chapters. Drop me a note if you're\ninterested.\n\nIf you make changes or add chapters, please fill the `test/expectations`\nfile and run the tests (`test/run.sh`).\nSee the `test/run.sh` file for (a bit) more information.\n\nWhen adding a new chapter (e.g. `step-NN`), please issue:\n\n```bash\ncd step-99\nln -sf ../step-NN/{hosts,roles,site.yml,group_vars,host_vars} .\n```\n\nFor typos, grammar, etc... please send a PR for the master branch\ndirectly.\n\nThank you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleucos%2Fansible-tuto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleucos%2Fansible-tuto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleucos%2Fansible-tuto/lists"}