{"id":21129604,"url":"https://github.com/pimvh/libvirt","last_synced_at":"2025-10-11T17:37:23.162Z","repository":{"id":151279179,"uuid":"592882145","full_name":"pimvh/libvirt","owner":"pimvh","description":"Ansible role to manage libvirt VMs","archived":false,"fork":false,"pushed_at":"2023-08-20T19:31:43.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T17:37:21.665Z","etag":null,"topics":["ansible","dualstack","hypervisor","role","vm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pimvh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-01-24T18:32:23.000Z","updated_at":"2023-06-06T08:11:12.000Z","dependencies_parsed_at":"2024-11-20T21:19:11.729Z","dependency_job_id":null,"html_url":"https://github.com/pimvh/libvirt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pimvh/libvirt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimvh%2Flibvirt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimvh%2Flibvirt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimvh%2Flibvirt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimvh%2Flibvirt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pimvh","download_url":"https://codeload.github.com/pimvh/libvirt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimvh%2Flibvirt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008121,"owners_count":26084397,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ansible","dualstack","hypervisor","role","vm"],"created_at":"2024-11-20T05:26:04.727Z","updated_at":"2025-10-11T17:37:23.147Z","avatar_url":"https://github.com/pimvh.png","language":"Python","readme":"![Molecule test](https://github.com/pimvh/libvirt/actions/workflows/test.yaml/badge.svg)\n\n# Requirements\n\n1. Ansible installed:\n\n```bash\nsudo apt install python3\npython3 -m ensurepip --upgrade\npip3 install ansible\n```\n\n2. Requirements.yaml installed (this role uses [pimvh.cloud_init](https://github.com/pimvh/cloud_init) for templating a cloud-init configuration):\n\n```bash\nansible-galaxy install -r requirements.yaml\n```\n\n## Required variables\n\nReview the variables as shown in defaults.\n\n```yaml\n\n# additional libvirt pools to created with XML definition\nlibvirt_pools:\n  - name: default\n    dir: \"\"\n    # I recommend using a lookup here\n    xml: '{{ lookup(\"file\", \"pools/default.xml\") }}'\n\n# additional libvirt networks to create\nlibvirt_networks:\n  - name: default\n    dir: \"\"\n    # I recommend using a lookup here\n    xml: '{{ lookup(\"file\", \"networks/default.xml\") }}'\n\n# Variables to pass to underlying cloud_init role\n# Cannot be set per VM\nlibvirt_cloud_init_add_to_known_hosts: true\nlibvirt_cloud_init_reboot_on_finish: true\nlibvirt_cloud_init_custom: false\n\n# do not pass when you do not want ansible pull\nansible_pull_config:\n  enabled: true # to enable ansible pull\n  # these params are skippable if you disable this (enable: false)\n  repo_owner: \"\"\n  repo_name: \"\"\n  playbook_name: \"\"\n  deploy_key_name: \"Ansible-pull deploy key\" # name of the deploy as shown in Github\n\nssh_ca_config:\n  enabled: true # to enable SSH CAs\n  # these params are skippable if you disable this (enable: false)\n  host_ca_privatekey: \"\" # remember to check whether this has the correct line endings\n  host_ca_privatekey_pass: \"\" # the passphrase of this private key of the host ca\n  host_ca_publickey: \"\" # public key of the host ca\n  user_ca_publickeys:\n    - \"\" # list of public keys\n\nlibvirt_virtual_machines:\n  - name: guest-01\n    ram: 2048\n    disksize: 20\n    vcpus: 2\n    networks:\n      - vrbr1\n    os: ubuntujammy\n    pool: default\n    image:\n      url: https://cloud-images.ubuntu.com/daily/server/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img\n      hashes_url: https://cloud-images.ubuntu.com/daily/server/jammy/current/SHA256SUMS\n\n    # see nested config above\n    ansible_pull: \"{{ ansible_pull_config }}\"\n    ssh_ca: \"{{ ssh_ca_config }}\"\n\n    # passing config like this is easiest (if you want the same across VMs)\n    ansible_pull: \"{{ ansible_pull_config | combine({'ansible_user_passwd_hash': var_that_holds_password })}}\"\n    ssh_ca: \"{{ ssh_ca_config }}\"\n\n    # This will be passed to underlying cloudinit role\n    cloud_init_userdata:\n      hostname: guest-01\n      fqdn: guest-01.example.com\n      groups: []\n      users:\n        - name: johndoe\n          gecos: John Doe\n          shell: /bin/bash\n          sudo: ALL=(ALL) NOPASSWD:ALL # Passwordless sudo, can be omitted\n          groups: sudo                 # for sudo access\n          lock_passwd: false\n          # I recommend to use ansible filters for this: {{ guest01_password | password_hash('sha512') }}\n          # do not save secrets in plaintext.\n          passwd: \"passwordhash\"\n      runcmd: []\n\n    cloud_init_networkdata: # This will be passed to underlying cloudinit role\n      # Either define IPs\n      ipv4: \u003c\u003c ipv4 \u003e\u003e\n      ipv6: \u003c\u003c ipv6 \u003e\u003e\n      # --- OR ---\n      # dump an entire netplan\n      # like the following\n      # netplan:\n      #   network:\n      #     version: 2\n      #     ethernets:\n      #       enp1s0:\n      #         dhcp4: false\n      #         addresses:\n      #           - \u003c\u003c addr \u003e\u003e\n      #         gateway4: \u003c\u003c addr \u003e\u003e\n      #         gateway6: \u003c\u003c addr \u003e\u003e\n      #         nameservers:\n      #           addresses:\n      #           - \u003c\u003c dns_server ip \u003e\u003e\n```\n\nData within `cloud_init_userdata` and `cloud_init_networkdata` is passed directly to the underlying role pimvh.cloud_init.\n\nSee [the README.md of that repository](https://github.com/pimvh/cloud_init) for more information.\n\n# Example playbook\n\n```yaml\nhosts:\n  - foo\nroles:\n  - pimvh.libvirt\n\n```\n\n# TLDR - What will happen if I run this\n\n- Assert required variables are defined\n- Check if required variables are defined for a VM\n- Fetch required image.\n- Add the required networks and pools\n- Generating a cloud-init config (see underlying role)\n- Create VM.\n- Reboot the VM when requested.\n\n# Future Improvements\n\n- clean up the cloud_init configuration\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimvh%2Flibvirt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpimvh%2Flibvirt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimvh%2Flibvirt/lists"}