{"id":15668858,"url":"https://github.com/alancoding/utility-playbooks","last_synced_at":"2025-02-22T11:43:39.110Z","repository":{"id":144899890,"uuid":"50455429","full_name":"AlanCoding/utility-playbooks","owner":"AlanCoding","description":"Ansible playbooks for various things that need to be done","archived":false,"fork":false,"pushed_at":"2022-10-20T15:14:24.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-03T05:38:35.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/AlanCoding.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":"2016-01-26T20:01:05.000Z","updated_at":"2022-10-03T20:27:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"83a25247-d463-42a4-b3bb-cac3b1fb6aba","html_url":"https://github.com/AlanCoding/utility-playbooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Futility-playbooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Futility-playbooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Futility-playbooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Futility-playbooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlanCoding","download_url":"https://codeload.github.com/AlanCoding/utility-playbooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240170064,"owners_count":19759143,"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":[],"created_at":"2024-10-03T14:20:21.195Z","updated_at":"2025-02-22T11:43:39.082Z","avatar_url":"https://github.com/AlanCoding.png","language":"Python","readme":"# utility-playbooks\nAnsible playbooks for various things that need to be done\n\nThings that these do\n\n - install simplejson on a system\n - install python rpm bindings\n - install python apt bindings for Fedora\n\n### Cloud Module Testing\n\nThis playbook serves the role of testing authentication to various\nAnsible modules.\n\nExample:\n\n```\nansible-playbook -i localhost, cloud_module_testing.yml -e ansible_python_interpreter=$(which python) --tags=tower\n```\n\nthis command will yield a number of possible results:\n\n - error due to `ansible-tower-cli` not being installed\n - authentication failure to host `127.0.0.1`\n - authentication failure to provided host\n - success\n\nWhy might it attempt to connect to `127.0.0.1` there? Because this is the\ndefault setting value! If the intent was to provide a host, then failing\nto connect to _this_ host is an indicator that the authentication was\nnot correctly specified.\n\n### Collection Conflict Testing\n\nThere are two folders which offer a collection by the same name.\nThese collection namespaces are `cow1.sounds` and `cow2.sounds`.\nThe playbook `cow.yml` will invoke the `moo` module which exists in\nboth collections.\n\nThe point here is to test which module will be ran.\n\nRun just one module:\n\n```\nANSIBLE_COLLECTIONS_PATHS=cow1 ansible-playbook -i localhost, cow.yml\nANSIBLE_COLLECTIONS_PATHS=cow2 ansible-playbook -i localhost, cow.yml\n```\n\nthe first cow makes a short \"moo\", the second cow makes a longer and\nmore lifelike moo-like sound.\n\nNow, make them compete.\n\n```\nANSIBLE_COLLECTIONS_PATHS=cow2:cow1 ansible-playbook -i localhost, cow.yml\nANSIBLE_COLLECTIONS_PATHS=cow1:cow2 ansible-playbook -i localhost, cow.yml\n```\n\nYou can see that the output in both of these cases is different.\nThe 2nd one does \"moo\".\nThis means that the 1st entry has higher precedence.\n\n### Colored Output\n\nThis playbook runs a command that produces colored output.\nNormally the output is not shown, but it will be if you run in\nverbose mode or if you use a callback plugin.\n\n```\nansible-playbook -i localhost, -e ansible_python_interpreter=$(which python) color_outputs.yml -vvv\nANSIBLE_STDOUT_CALLBACK=json ansible-playbook -i localhost, -e ansible_python_interpreter=$(which python) color_outputs.yml\n```\n\n### Test Use of collection\n\n```\nansible-galaxy collection install chrismeyersfsu.tower_modules:0.0.1 -p alan\nANSIBLE_COLLECTIONS_PATHS=alan ansible-playbook -i localhost, -e ansible_python_interpreter=$(which python) tower_module_chris.yml\n```\n\nThis will run a tower module, but this is not enough information to say it worked,\nbecause the same modules already exist in Ansible core. To verify that, modify\nyour local Ansible install with the diff:\n\n```\ndiff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py\nindex bba58d8894..f3e9586e69 100644\n--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py\n+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py\n@@ -88,6 +88,7 @@ def main():\n             module.fail_json(msg='Failed to update the organization: {0}'.format(excinfo), changed=False)\n\n     json_output['changed'] = result['changed']\n+    json_output['this_is_the_old_one'] = True\n     module.exit_json(**json_output)\n```\n\nAnd then run without the collection:\n\n```\nansible-playbook -i localhost, -e ansible_python_interpreter=$(which python) tower_module_chris.yml\n```\n\nThat output (and not the output when using the 'alan' collection path) should\ncontain `\"this_is_the_old_one\": true`.\nThis will confirm that the collection is working.\n\n#### Doc Fragments\n\nfrom issue https://github.com/ansible/ansible/issues/56226, we use the -M flag\nas well as setting the collection path.\n\nworks:\n\n```\nANSIBLE_COLLECTIONS_PATHS=alan ansible-doc -M alan/ansible_collections/chrismeyersfsu/tower_modules/plugins/modules/ -t module tower_organization\n```\n\nwrong:\n\n```\nansible-doc -M alan/ansible_collections/chrismeyersfsu/tower_modules/plugins/modules/ -t module tower_organization\nERROR! module tower_organization missing documentation (or could not parse documentation): unknown doc_fragment(s) in file /Users/alancoding/Documents/repos/utility-playbooks/alan/ansible_collections/chrismeyersfsu/tower_modules/plugins/modules/tower_organization.py: chrismeyersfsu.tower_modules.tower\n```\n\ngives the wrong docs:\n\n```\nANSIBLE_COLLECTIONS_PATHS=alan ansible-doc -t module tower_organization\n```\n\n#### Collection playbooks\n\nRun the collection playbooks\n\n```\ntower-cli login admin\nansible-playbook -i localhost, galaxy_setup.yml -e ansible_python_interpreter=$(which python)\n```\n\nThis assumes that you have tower-cli installed to the virtual environment\nwhere you are running Ansible itself.\n\nFrom there, you can either launch the job template, or you can run this stuff\nmanually.\n\n```\nansible-playbook -i localhost, galaxy_upload.yml -e ansible_python_interpreter=$(which python) -e collection_version=0.0.2 -e galaxy_token=\u003cadd_yo_token\u003e\nrm -rf awx_clone\n```\n\nRemoving the clone isn't necessary, but you know... clean up after yourself.\n\nIf the collection already exists, it should give you this:\n\n```\nTASK [publish-collection : publish the collection] ****************************\nok: [localhost]\n```\n\nNow test by installing the latest from Galaxy.\n\n```\nansible-galaxy collection install alancoding.awx -p alan\n```\n\nThis should not require any authentication.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falancoding%2Futility-playbooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falancoding%2Futility-playbooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falancoding%2Futility-playbooks/lists"}