{"id":15716475,"url":"https://github.com/cloudymax/ansible-boilerplate","last_synced_at":"2025-03-30T20:49:25.399Z","repository":{"id":64837929,"uuid":"555759942","full_name":"cloudymax/ansible-boilerplate","owner":"cloudymax","description":"collection my frequently used ansible roles","archived":false,"fork":false,"pushed_at":"2023-06-17T04:20:16.000Z","size":62,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:36:33.809Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudymax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-10-22T09:02:49.000Z","updated_at":"2022-10-22T09:07:22.000Z","dependencies_parsed_at":"2024-10-24T13:12:17.597Z","dependency_job_id":"7b73918a-9cd6-4e2b-912a-b5486b308d3a","html_url":"https://github.com/cloudymax/ansible-boilerplate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudymax%2Fansible-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudymax%2Fansible-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudymax%2Fansible-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudymax%2Fansible-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudymax","download_url":"https://codeload.github.com/cloudymax/ansible-boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379385,"owners_count":20767696,"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-03T21:45:47.426Z","updated_at":"2025-03-30T20:49:25.373Z","avatar_url":"https://github.com/cloudymax.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Its just Ansible [![GitHub Release](https://img.shields.io/github/v/release/cloudymax/ansible-boilerplate?style=flat\u0026labelColor=858585\u0026color=6BF847\u0026logo=GitHub\u0026logoColor=white)](https://github.com/cloudymax/ansible-boilerplate/releases)\n\n- A bunch of Ansible roles \n- a playbook the runs any role you define in a yaml file\n- a script that runs the playbook for each the roles you defined\n- For when Cloud-init, Terraform and baked images cant help you.\n- Seriously, try Cloud-init, Terraform and baked images first.\n\n## Provision localhost\n\n  1. Clone this repo.\n  2. `cd public-infra/ansible`\n  3. `bash provision.sh`\n\n## Ansible Profiles\n\n  - Existing profiles can be found in the [ansible_profiles](public-infra/ansible/ansible_profiles) directory\n\n  - Create your own profile [HERE](onboardme/configs/ansible_profiles/README.md)\n\n\n## Roles\n\n- Each role is just a brick of basic logic to loop over with a list.\n\n- you can find a list of available roles and their fields/values in [ansible_profiles/README.md](ansible/configs/ansible_profiles/README.md)\n\n## Flow:\n\n1. `/profile/0_step.yaml` contains a list of actions of the same type.\n    \n    For example:\n\n      ```yaml\n      # this yaml file contains a list of 2 commands\n      ---\n      Commands:\n        - Command: gpg --dearmor githubcli-archive-keyring.gpg\n          Become: yes\n          Become_User: vmadmin\n          Become_Method: sudo\n        - Command: # another command to run\n          Become: # pretend to be a specific user yes/no\n          Become_User: # the user to pretend to be\n          Become_Method: # how to do it, sudo/su\n      ```\n\n2. `ansible/demo.sh` passes `/profile/0_step.yaml` to ansible as `-extra-vars \"profile_path='${PROFILE_PATH}'`.\n\n    ```zsh\n    # provision the Host with an ansible profile\n\n        for file in /\"${DEMO_DIR}\"/*.yaml\n        do\n            export PROFILE_PATH=$file\n\n            echo \"running $file ...\"\n            time ansible-playbook -i $ANSIBLE_INVENTORY_FILE \\\n                $ANSIBLE_PLAYBOOK \\\n                -u $ANSIBLE_REMOTE_USER \\\n                --extra-vars \\\n                \"profile_path='${PROFILE_PATH}' \\\n                ssh_key_path='${VM_KEY_FILE}' \\\n                synced_directory='${SYNCED_DIR}' \\\n                ansible_user='$VM_USER' \\\n                squash='${SQUASH}' \\\n                debug_output='${DEBUG}' \\\n                $VERBOSITY\"\n\n        done\n    ```\n\n3. for each item in the list, `ansible/playbooks/main-program.yaml` will execute the appropriate ansible function\n\n    ```yaml\n      tasks:\n      - name: git_clone\n        include_role:\n          name: git_clone\n        when:\n          - hostvars['localhost'].profile_json['Repos'] is defined\n          - (hostvars['localhost'].profile_json['Repos']|length\u003e0)\n\n      - name: download items\n        include_role:\n          name: downloads\n        when:\n          - hostvars['localhost'].profile_json['Downloads'] is defined\n          - (hostvars['localhost'].profile_json['Downloads']|length\u003e0)\n    ```\n\n\n## Mitogen Optimizations\n\nMitogen’s main feature is enabling your Python program to self-replicate and control/communicate with new copies of itself running on remote machines, using only an existing installed Python interpreter and SSH client. (something that by default can be found on almost all contemporary machines in the wild) To accomplish this, Mitogen uses a single 400 byte SSH command line and 8KB of its own source code sent to stdin of the remote SSH connection.\n\n  - [Guide](https://www.toptechskills.com/ansible-tutorials-courses/speed-up-ansible-playbooks-pipelining-mitogen/)\n\n  - [Mitogen for Ansible](https://mitogen.networkgenomics.com/ansible_detailed.html)\n\n  - [download](https://networkgenomics.com/try/mitogen-0.2.9.tar.gz)\n\n  - Be aware that mitogen is on a much slower cadence thn ansible and does not support the latest version.\n      \n      \u003e # ERROR! Your Ansible version (2.11.7) is too recent. The most recent version\n        # supported by Mitogen for Ansible is (2, 10).x. Please check the Mitogen\n        # release notes to see if a new version is available, otherwise\n        # subscribe to the corresponding GitHub issue to be notified when\n        # support becomes available.\n    \n    \n    ```zsh\n\n    pip3 install ansible-base==2.10.16\n\n    wget https://networkgenomics.com/try/mitogen-0.2.9.tar.gz\n\n    tar -xvf mitogen-0.2.9.tar.gz\n    rm mitogen-0.2.9.tar.gz\n\n    ```\n\n- Add to `ansible.cfg`:\n\n    ```yaml\n    [defaults]\n    strategy_plugins = mitogen-0.2.9/ansible_mitogen/plugins/strategy\n    strategy = mitogen_linear\n\n    ```\n\n## Pipelining Optimizations\n\nPipelining, if supported by the connection plugin, reduces the number of network operations required to execute a module on the remote server, by executing many Ansible modules without actual file transfer. \n\nThis can result in a very significant performance improvement when enabled. However this conflicts with privilege escalation (become). For example, when using ‘sudo:’ operations you must first disable ‘requiretty’ in /etc/sudoers on all managed hosts, which is why it is disabled by default. \n\nThis option is disabled if ANSIBLE_KEEP_REMOTE_FILES is enabled. This is a global option, each connection plugin can override either by having more specific options or not supporting pipelining at all.\n\n- Read the docs [here](https://docs.ansible.com/ansible/latest/reference_appendices/config.html)\n\nTo enable SSH Multiplexing:\n\n1. in `ansible/ansible.cfg`, add:\n\n    ```yaml\n    [ssh_connection]\n    pipelining = True\n    transfer_method = smart\n    retries = 3\n    ```\n\n2. To your inventory, `ansible/ansible.cfg` or connection string add:\n\n    ```yaml\n          ansible_ssh_common_args: \"-o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPath=~/.ssh/ansible-%r@%h:%p\"\n    ```\n\n- Warning about multiplexing:\n\n    \u003e When using SSH Multiplexing with longer ControlPersist time, there is a potential trouble, if you sleep your notebook/pc and wake it again with existing MUX connections. By doing this, your connections will be broken, but still staying as Persistent, which will break your ssh connectivity  to the muxed hosts. \n\n    For fixing it, you will have to kill the SSH [mux] containing processes\n\n    - https://gryzli.info/2019/02/21/tuning-ansible-for-maximum-performance/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudymax%2Fansible-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudymax%2Fansible-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudymax%2Fansible-boilerplate/lists"}