{"id":18363443,"url":"https://github.com/stuttgart-things/download-install-binary","last_synced_at":"2025-04-10T06:49:41.774Z","repository":{"id":162969838,"uuid":"612223359","full_name":"stuttgart-things/download-install-binary","owner":"stuttgart-things","description":"download and install binary files","archived":false,"fork":false,"pushed_at":"2024-04-12T12:50:34.000Z","size":77,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-04-12T15:07:47.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/stuttgart-things.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}},"created_at":"2023-03-10T13:17:30.000Z","updated_at":"2024-04-15T08:54:35.123Z","dependencies_parsed_at":"2024-04-15T09:04:53.898Z","dependency_job_id":null,"html_url":"https://github.com/stuttgart-things/download-install-binary","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/stuttgart-things%2Fdownload-install-binary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuttgart-things%2Fdownload-install-binary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuttgart-things%2Fdownload-install-binary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuttgart-things%2Fdownload-install-binary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuttgart-things","download_url":"https://codeload.github.com/stuttgart-things/download-install-binary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173850,"owners_count":21059595,"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-11-05T23:06:33.836Z","updated_at":"2025-04-10T06:49:41.752Z","avatar_url":"https://github.com/stuttgart-things.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"stuttgart-things/download-install-binary\n=======================\n\nThis Role downloads binaries and unarchives them for installation. It can also remove installed binaries.\n\n\u003cdetails\u003e\u003csummary\u003eROLE DESCRIPTION\u003c/summary\u003e\n\nThis role includes the following tasks:\n- check whether the binary has been installed, and whether it locates in the ```bin_dir```\n- Install (when ```wanted_state=\"present\"```, default) or delete (when ```wanted_state=\"absent\"```) the binary file. The parameter ```wanted_state``` is usually overwriten by a config-file, e.g. cherry file.\n- If binary installed and version check required, the role checks binary version. When the wanted version does not match the installed version, it proceeds with the installation, otherwise the installation tasks are skipped to save time.\n\nThe process of installing binary:\n- unarchive -\u003e download and unarchive the zip-file for installation (also works for tar.gz and binary)\n- copy -\u003e copy the binary to bin-folder\n- remove -\u003e remove the downloaded directory.\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eROLE VARIABLES\u003c/summary\u003e\n\nThe role takes in a python dictionary with the following values:\n* bin_name: binary name\n* bin_version: binary version\n* source_url: the link to the installation file\n* bin_to_copy: path of the binary, which will be copied to bin-folder\n* to_remove: path of the downloaded and unpacked installation file, which will be removed\n* bin_dir: directory of the bin-folder, usually \"/usr/bin/\" or \"/usr/local/bin/\".\n* version_cmd: command to get current binary version\n* target_version: binary version value to compare with current binary version\n* md5_checksum: hash of current binary version\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eROLE INSTALLATION\u003c/summary\u003e\n\n```bash\ncat \u003c\u003cEOF \u003e ./requirements.yaml\nroles:\n- src: https://github.com/stuttgart-things/download-install-binary.git\n  scm: git\n\ncollections:\n- name: community.general\n  version: 8.5.0\nEOF\n\nansible-galaxy install -r ./requirements.yaml --force\nansible-galaxy collection install -r ./requirements.yaml -f\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eEXAMPLE INVENTORY\u003c/summary\u003e\n\n```bash\ncat \u003c\u003cEOF \u003e inv\n[appserver]\n1.2.3.4 ansible_user=sthings\nEOF\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eEXAMPLE PLAYBOOK - BINARIES INLINE\u003c/summary\u003e\n\n```yaml\ncat \u003c\u003cEOF \u003e download-install-binary.yaml\n- hosts: all\n  become: true\n  vars:\n    download_dir: \"/tmp/downloads\" # dir will be created if it doesent exists\n    bin:\n      kubectl:\n        bin_name: \"kubectl\"\n        bin_version: \"1.29.3\"\n        check_bin_version_before_installing: true\n        source_url: \"https://dl.k8s.io/v1.29.3/bin/linux/amd64/kubectl\" # just the binary\n        bin_to_copy: \"kubectl\"\n        to_remove: \"kubectl\"\n        bin_dir: \"/usr/local/bin\"\n        version_cmd: \" version --client\"\n        target_version: v1.29.3\n        md5_checksum: \"07b43208389cbc779941b94a05cf89bc\" # md5 checksum given\n      packer:\n        bin_name: \"packer\"\n        bin_version: \"1.10.2\"\n        check_bin_version_before_installing: true\n        source_url: \"https://releases.hashicorp.com/packer/1.10.2/packer_1.10.2_linux_amd64.zip\" # zipped binary\n        bin_to_copy: \"packer\"\n        to_remove: \"packer\"\n        bin_dir: \"/usr/local/bin\"\n        version_cmd: \" --version\"\n        target_version: v1.10.2\n        # md5 not checksum given\n      velero:\n        bin_name: \"velero\"\n        bin_version: \"1.13.1\"\n        check_bin_version_before_installing: true\n        source_url: \"https://github.com/vmware-tanzu/velero/releases/download/v1.13.1/velero-v1.13.1-linux-amd64.tar.gz\" # tar.gz binary\n        bin_to_copy: \"velero-v1.13.1-linux-amd64/velero\"\n        to_remove: \"velero-v1.13.1-linux-amd64\"\n        bin_dir: \"/usr/local/bin\"\n        version_cmd: \" version --client-only\"\n        target_version: v1.13.1\n        md5_checksum: \"30ab57f9520ae2318ab28eefbc81728c\" # md5 checksum given\n\n  tasks:\n    - name: Start download_install_binary\n      ansible.builtin.include_role:\n        name: download-install-binary\nEOF\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eEXAMPLE PLAYBOOK - BINARIES FROM VARS FILE\u003c/summary\u003e\n\n```yaml\ncat \u003c\u003cEOF \u003e binaries.yaml\nbin:\n  velero:\n    bin_name: \"velero\"\n    bin_version: \"1.13.1\"\n    check_bin_version_before_installing: true\n    source_url: \"https://github.com/vmware-tanzu/velero/releases/download/v1.13.1/velero-v1.13.1-linux-amd64.tar.gz\"\n    bin_to_copy: \"velero-v1.13.1-linux-amd64/velero\"\n    to_remove: \"velero-v1.13.1-linux-amd64\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" version --client-only\"\n    target_version: v1.13.1\n    md5_checksum: \"30ab57f9520ae2318ab28eefbc81728c\"\n\n  terraform:\n    bin_name: \"terraform\"\n    bin_version: \"1.8.0\"\n    check_bin_version_before_installing: true\n    source_url: \"https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_amd64.zip\"\n    bin_to_copy: \"terraform\"\n    to_remove: \"terraform\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" --version\"\n    target_version: v1.8.0\n    md5_checksum: \"2c6638e53cf5474c4d1363c17e8653ef\"\n\n  helm:\n    bin_name: \"helm\"\n    bin_version: \"3.14.3\"\n    check_bin_version_before_installing: true\n    source_url: \"https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz\"\n    bin_to_copy: \"linux-amd64/helm\"\n    to_remove: \"linux-amd64\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" version\"\n    target_version: v3.14.3\n    md5_checksum: \"8dd2ecdbb70ef4e3a55083e8d5ebf352\"\n\n  kubectl:\n    bin_name: \"kubectl\"\n    bin_version: \"1.29.3\"\n    check_bin_version_before_installing: true\n    source_url: \"https://dl.k8s.io/v1.29.3/bin/linux/amd64/kubectl\"\n    bin_to_copy: \"kubectl\"\n    to_remove: \"kubectl\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" version --client\"\n    target_version: v1.29.3\n    md5_checksum: \"07b43208389cbc779941b94a05cf89bc\"\n\n  packer:\n    bin_name: \"packer\"\n    bin_version: \"1.10.2\"\n    check_bin_version_before_installing: true\n    source_url: \"https://releases.hashicorp.com/packer/1.10.2/packer_1.10.2_linux_amd64.zip\"\n    bin_to_copy: \"packer\"\n    to_remove: \"packer\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" --version\"\n    target_version: v1.10.2\n    md5_checksum: \"374f22185f1f8cb25bc53187a2154ef0\"\n\n  k9s:\n    bin_name: \"k9s\"\n    bin_version: \"0.32.4\"\n    check_bin_version_before_installing: true\n    source_url: \"https://github.com/derailed/k9s/releases/download/v0.32.4/k9s_Linux_amd64.tar.gz\"\n    bin_to_copy: \"k9s\"\n    to_remove: \"k9s\"\n    bin_dir: \"/usr/local/bin\"\n    version_cmd: \" version --short\"\n    target_version: v0.32.4\n    md5_checksum: \"04ba6f524a433f8ceb9095c4c8292240\"\n\nEOF\n```\n\n```yaml\ncat \u003c\u003cEOF \u003e download-install-binary.yaml\n- hosts: all\n  become: true\n  vars_files:\n    - binaries.yaml\n\n  tasks:\n    - name: Start download_install_binary\n      ansible.builtin.include_role:\n        name: download-install-binary\nEOF\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eGET MD5 FROM INSTALLED BINARY\u003c/summary\u003e\n\n```yaml\ncat \u003c\u003cEOF \u003e get-md5.yaml\n---\n- hosts: \"{{ target_host | default('all') }}\"\n  become: true\n  vars:\n    bin_dir: /usr/local/bin\n    binary_name: nerdctl\n\n  tasks:\n    - name: \"Calculate MD5 Checksum from file {{ item.value.bin_dir }}/{{ item.value.bin_name }}\"\n      ansible.builtin.stat:\n        path: \"{{ bin_dir }}/{{ binary_name }}\"\n        checksum_algorithm: md5\n      register: status_checksum\n\n    - name: Output checksum\n      ansible.builtin.debug:\n        var: status_checksum.stat.checksum\nEOF\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eEXAMPLE EXECUTION\u003c/summary\u003e\n\n```bash\n# INSTALL BINARIES\nansible-playbook -i inv download-install-binary.yaml -vv\n\n# UNINSTALL BINARIES\nansible-playbook -i inv download-install-binary.yaml -vv -e wanted_state=absent\n\n# GET MD5\nansible-playbook -i inv get-md5.yaml -vv\n```\n\n\u003c/details\u003e\n\n\nROLE HISTORY\n----------------\n| DATE  | WHO | CHANGELOG |\n|---|---|---|\n|2024-04-17  | Andre Ebert | Changed role structure and added linter skip rules.\n|2020-10-23  | Christian Mueller | Updated for using of ansible collections, fixed role structure\n|2020-04-10  | Patrick Hermann | added ability to download non zip and tar files\n|2020-03-30  | Xiaomin Lai | intial commit for this role in codehub\n\n## License\n\u003cdetails\u003e\u003csummary\u003eLICENSE\u003c/summary\u003e\n\nCopyright 2020 patrick hermann.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\u003c/details\u003e\n\nAuthor Information\n------------------\n\n```yaml\nXiaomin Lai, 03/2020, xiaomin.lai@sva.de, Stuttgart-Things\nPatrick Hermann, 03/2020, patrick.hermann@sva.de, Stuttgart-Things\nAndre Ebert, 04/2024, andre.ebert@sva.de, Stuttgart-Things\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuttgart-things%2Fdownload-install-binary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuttgart-things%2Fdownload-install-binary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuttgart-things%2Fdownload-install-binary/lists"}