{"id":15979012,"url":"https://github.com/greg-hellings/ansible_collection_demo","last_synced_at":"2026-03-06T22:33:01.467Z","repository":{"id":137511771,"uuid":"290963835","full_name":"greg-hellings/ansible_collection_demo","owner":"greg-hellings","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-28T13:52:54.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T09:58:25.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/greg-hellings.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}},"created_at":"2020-08-28T05:59:48.000Z","updated_at":"2020-08-28T13:52:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbfaf143-e62b-44ee-99ed-a6190f1449fa","html_url":"https://github.com/greg-hellings/ansible_collection_demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/greg-hellings/ansible_collection_demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fansible_collection_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fansible_collection_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fansible_collection_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fansible_collection_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greg-hellings","download_url":"https://codeload.github.com/greg-hellings/ansible_collection_demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fansible_collection_demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30201014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-07T23:40:39.197Z","updated_at":"2026-03-06T22:33:01.430Z","avatar_url":"https://github.com/greg-hellings.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Collection Demo\n\n## Before You Begin\n\nBefore you begin you will need to install [vagrant](http://vagrantup.com),\n[vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt), and\n[ansible](https://github.com/ansible/ansible). After that, you will need to\ninstall the devroles.devel collection in Ansible like such:\n\n`ansible-galaxy collection install devroles.devel`\n\n## Begin\n\nBegin the demo by bringing up the Ansible machine (requires vagrant/libvirt)\n\n`vagrant up --no-provision`\n\nDepending on the speed of your system and the speed of your Internet connection, this\ncould run for a while.\n\n## Run the playbook to setup the system\n\n`vagrant provision`\n\nSee the output [here](https://htmlpreview.github.io/?https://github.com/greg-hellings/ansible_collection_demo/blob/master/01_SystemSetup.html)\nfor the playbook run.\n\n## Login to the system and clone the repositories\n\n```bash\nvagrant ssh\ncd ansible_collections/oasis_roles/\ngit clone https://github.com/oasis-roles/ansible_collection_system system\ngit clone https://github.com/oasis-roles/ansible_collection_osp osp\n```\n\nThe role oasis\\_roles.system is now ready for use. See the steps executed [here](https://htmlpreview.github.io/?https://github.com/greg-hellings/ansible_collection_demo/blob/master/02_CloneRepos.html)\nalthough it's not really much more than some git clones. Now here is what the home directory looks like\nunder the ansible\\_collections/ folder:\n\n\u003cpre\u003e[vagrant@localhost ~]$ tree ansible_collections/ -L 3\n\u003cfont color=\"#0087FF\"\u003eansible_collections/\u003c/font\u003e\n└── \u003cfont color=\"#0087FF\"\u003eoasis_roles\u003c/font\u003e\n    ├── \u003cfont color=\"#0087FF\"\u003eosp\u003c/font\u003e\n    │   ├── AUTHORS\n    │   ├── galaxy.yml\n    │   ├── LICENSE\n    │   ├── \u003cfont color=\"#0087FF\"\u003eplugins\u003c/font\u003e\n    │   ├── README.md\n    │   ├── requirements.yml\n    │   ├── \u003cfont color=\"#0087FF\"\u003eroles\u003c/font\u003e\n    │   ├── \u003cfont color=\"#0087FF\"\u003etests\u003c/font\u003e\n    │   └── tox.ini\n    └── \u003cfont color=\"#0087FF\"\u003esystem\u003c/font\u003e\n        ├── AUTHORS\n        ├── galaxy.yml\n        ├── Jenkinsfile\n        ├── LICENSE\n        ├── \u003cfont color=\"#0087FF\"\u003eplugins\u003c/font\u003e\n        ├── README.md\n        ├── requirements.yml\n        ├── \u003cfont color=\"#0087FF\"\u003eroles\u003c/font\u003e\n        ├── \u003cfont color=\"#0087FF\"\u003etests\u003c/font\u003e\n        └── tox.ini\n\n9 directories, 13 files\u003c/pre\u003e\n\n## Create a sample playbook\n\n```bash\nvagrant ssh\ncat \u003e playbook.yml \u003c\u003c EOD\n- hosts: localhost\n  roles:\n    - oasis_roles.system.users_and_groups\n  vars:\n    users_and_groups_add_modify_users:\n      - name: someuser\nEOD\n. ~/ansible-venv/bin/activate\nansible-playbook playbook.yml\n```\n\nYou should now be able to change to the user \"someuser\" using\n\n```bash\nsudo su - someuser\npwd\n```\n\nObserve that the results can be seen [here](https://htmlpreview.github.io/?https://github.com/greg-hellings/ansible_collection_demo/blob/master/03_RunPlaybook.html)\n\n## Create a new role or collection\n\n```bash\nvagrant ssh\n. ~/ansible-venv/bin/activate\ncd ansible_collections/\nansible-galaxy collection init --collection-skeleton ~/meta_ansible_collection_template testing.tests\ncd testing/tests\ngit init .\ngit submodule add https://github.com/oasis-roles/meta_test tests\ncd roles\nansible-galaxy init test_role\ncd test_role\n# Create the tasks for the role\ncat \u003e tasks/main.yml \u003c\u003c EOD\n- name: do the things\n  debug:\n    msg: I can do all the things!\nEOD\n# Create a test for the role\ncat \u003e molecule/docker/tests/test_null.py \u003c\u003c EOD\ndef test_nothing(host):\n    assert host.file(\"/etc\").exists\nEOD\ncd ../..\n```\n\nYou have now created your first role inside of a collection! You can test it now with tox-ansible\nvery easily. (Getting Docker running on Fedora 32 is beyond the scope of this document, but you\ncan find more about it [here](https://fedoramagazine.org/docker-and-fedora-32/) including a description\nof why it does not work out of the box).\n\n```bash\n# List all the environments\ntox -l\n# Run the specific scenario we need\ntox -e test_role-docker\n```\n\nOnce again, you can see the results [here](https://htmlpreview.github.io/?https://github.com/greg-hellings/ansible_collection_demo/blob/master/04_CreateCollection.html)\n\n## BONUS ROUND!\n### Adding existing roles from Github to the collection\n\nBefore you go farther, you will need to have a clean git tree. This can be done by committing whatever\nyou have in the collection so far. On the Vagrant VM you will need to set the global git config\nwith your email and user name before making that commit\n\n```bash\ngit config --global user.name \"Greg Hellings\"\ngit config --global user.email greg.hellings@gmail.com\n```\n\nSay I have a role that already lives somewhere that I want to move into my new collection. Is\nthere a way to do that efficiently? Well, since you asked! Some of these changes are very specific\nto our OASIS collections, and each role will require manually checking which parts of the molecule.yml\nfile are edited, etc. However, the process is relatively straightforward and some parts of it are\nautomated with the sanitize\\_role.sh file that lives in this repository.\n\n```bash\n. ~/ansible-venv/bin/activate\ncd ~/ansible_collections/testing/tests\ngit init . \u0026\u0026 git add . \u0026\u0026 git commit -m \"First commit of test collection\"\n# This command requires no uncommited changes\ngit subtree add -P roles/users_and_groups https://github.com/oasis-roles/users_and_groups master\n# Removes lots of shared things all our roles have\n/vagrant/sanitize_role.sh\n# Edit the molecule files\nvi roles/users_and_groups/molecule/docker/molecule.yml\n# Remove things like the Github/Travis badge from the README.md file\nvi roles/users_and_groups/README.md\n# For MOST roles, these will be redundant, same with the ones in the openstack scenarios\ngit rm roles/users_and_groups/molecule/docker/{create.yml,destroy.yml,Dockerfile.j2}\n# For this particular role, this file is empty, and that causes breakages\ngit rm roles/users_and_groups/molecule/docker/tests/test_null.py\ntox -l\ntox -e users_and_groups-docker\n# Shows that all the history of the existing role lives in this repository, now\ngit log\n```\n\nYou can see a walkthrough of this by checking out my recording of it. As always, you can find it\n[here](https://htmlpreview.github.io/?https://github.com/greg-hellings/ansible_collection_demo/master/blob/05_ImportRole.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-hellings%2Fansible_collection_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreg-hellings%2Fansible_collection_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-hellings%2Fansible_collection_demo/lists"}