{"id":15750834,"url":"https://github.com/rgl/terraform-libvirt-ansible-windows-example","last_synced_at":"2025-07-23T15:04:36.247Z","repository":{"id":139753334,"uuid":"361178860","full_name":"rgl/terraform-libvirt-ansible-windows-example","owner":"rgl","description":"Terraform, Ansible, and Windows integration playground","archived":false,"fork":false,"pushed_at":"2025-05-05T20:28:54.000Z","size":148,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-18T17:48:55.396Z","etag":null,"topics":["ansible","libvirt","terraform","windows","wsl","wsl-setup","wsl-ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/rgl.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,"zenodo":null}},"created_at":"2021-04-24T14:10:27.000Z","updated_at":"2025-06-02T09:07:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3cb72ff-1bba-437c-9768-21a22393fd54","html_url":"https://github.com/rgl/terraform-libvirt-ansible-windows-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rgl/terraform-libvirt-ansible-windows-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fterraform-libvirt-ansible-windows-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fterraform-libvirt-ansible-windows-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fterraform-libvirt-ansible-windows-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fterraform-libvirt-ansible-windows-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgl","download_url":"https://codeload.github.com/rgl/terraform-libvirt-ansible-windows-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fterraform-libvirt-ansible-windows-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266699505,"owners_count":23970514,"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-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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","libvirt","terraform","windows","wsl","wsl-setup","wsl-ubuntu"],"created_at":"2024-10-04T07:00:21.866Z","updated_at":"2025-07-23T15:04:36.239Z","avatar_url":"https://github.com/rgl.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\n[![Build status](https://github.com/rgl/terraform-libvirt-ansible-windows-example/workflows/build/badge.svg)](https://github.com/rgl/terraform-libvirt-ansible-windows-example/actions?query=workflow%3Abuild)\n\nTerraform, Ansible, and Windows integration playground.\n\n## Usage (Ubuntu 22.04 host)\n\nCreate and install the [base Windows 2022 vagrant box](https://github.com/rgl/windows-vagrant).\n\nInstall the dependencies:\n\n* [Docker](https://docs.docker.com/engine/install/).\n* [Visual Studio Code](https://code.visualstudio.com).\n* [Dev Container plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).\n\nOpen this directory with the Dev Container plugin.\n\nOpen `bash` inside the Visual Studio Code Terminal.\n\nCreate the infrastructure:\n\n```bash\nterraform init\nterraform plan -out=tfplan\ntime terraform apply tfplan\n```\n\n**NB** if you have errors alike `Could not open '/var/lib/libvirt/images/terraform_example_root.img': Permission denied'` you need to reconfigure libvirt by setting `security_driver = \"none\"` in `/etc/libvirt/qemu.conf` and restart libvirt with `sudo systemctl restart libvirtd`.\n\nShow information about the libvirt/qemu guest:\n\n```bash\nvirsh dumpxml terraform_example\nvirsh qemu-agent-command terraform_example '{\"execute\":\"guest-info\"}' --pretty\nvirsh qemu-agent-command terraform_example '{\"execute\":\"guest-network-get-interfaces\"}' --pretty\n# NB the first command after a (re)boot will take some minutes until\n#    qemu-agent and winrm are available. the commands that follow it\n#    should execute quickly.\n# NB these command are executed as the local system user.\n./qemu-agent-guest-exec terraform_example winrm enumerate winrm/config/listener\n./qemu-agent-guest-exec terraform_example winrm get winrm/config\n```\n\nGet the guest ssh host public keys, convert them to the knowns hosts format,\nand show their fingerprints:\n\n```bash\n./qemu-agent-guest-exec-get-sshd-public-keys.sh \\\n  terraform_example \\\n  | tail -1 \\\n  | jq -r .sshd_public_keys \\\n  | sed \"s/^/$(terraform output --raw example_ip_address) /\" \\\n  \u003e example-ssh-known-hosts.txt\nssh-keygen -l -f example-ssh-known-hosts.txt\n```\n\nUsing your ssh client, open a shell inside the VM and execute some commands:\n\n```bash\nssh \\\n  -o UserKnownHostsFile=example-ssh-known-hosts.txt \\\n  \"vagrant@$(terraform output --raw example_ip_address)\"\nwhoami /all\nexit\n```\n\nConfigure the infrastructure:\n\n```bash\n#ansible-doc -l # list all the available modules\nansible-inventory --list --yaml\nansible-lint --offline --parseable playbook.yml\nansible-playbook playbook.yml --syntax-check\nansible-playbook playbook.yml --list-hosts\n\n# execute ad-hoc commands.\nansible -vvv -m gather_facts windows\nansible -vvv -m win_ping windows\nansible -vvv -m win_command -a 'whoami /all' windows\nansible -vvv -m win_shell -a '$FormatEnumerationLimit = -1; dir env: | Sort-Object Name | Format-Table -AutoSize | Out-String -Stream -Width ([int]::MaxValue) | ForEach-Object {$_.TrimEnd()}' windows\n\n# execute the playbook.\n# see https://docs.ansible.com/ansible-core/2.18/os_guide/windows_winrm.html#winrm-limitations\n# see https://docs.ansible.com/ansible-core/2.18/os_guide/windows_usage.html\n# see https://docs.ansible.com/ansible-core/2.18/os_guide/windows_faq.html#can-i-run-python-modules-on-windows-hosts\ntime ansible-playbook playbook.yml #-vvv\ntime ansible-playbook playbook.yml --limit wsl #-vvv\n```\n\nUsing your ssh client, open a shell inside the VM and execute some commands:\n\n```bash\nssh \\\n  -o UserKnownHostsFile=example-ssh-known-hosts.txt \\\n  \"vagrant@$(terraform output --raw example_ip_address)\"\nwhoami /all\nver\nwsl -d Ubuntu-24.04 id\nwsl -d Ubuntu-24.04 uname -a\nwsl -d Ubuntu-24.04 ps -efww --forest\nexit\n```\n\nDestroy the infrastructure:\n\n```bash\ntime terraform destroy -auto-approve\n```\n\nLint the source code:\n\n```bash\n./ansible-lint.sh --offline --parseable playbook.yml\n./mega-linter.sh\n```\n\nList this repository dependencies (and which have newer versions):\n\n```bash\nGITHUB_COM_TOKEN='YOUR_GITHUB_PERSONAL_TOKEN' ./renovate.sh\n```\n\n## Windows Management\n\nAnsible can use one of the native Windows management protocols: [psrp](https://docs.ansible.com/ansible-core/2.18/collections/ansible/builtin/psrp_connection.html) (recommended) or [winrm](https://docs.ansible.com/ansible-core/2.18/collections/ansible/builtin/winrm_connection.html).\n\nIts also advisable to use the `credssp` transport, as its the most flexible transport:\n\n| transport   | local accounts | active directory accounts | credentials delegation | encryption |\n|-------------|----------------|---------------------------|------------------------|------------|\n| basic       | yes            | no                        | no                     | no         |\n| certificate | yes            | no                        | no                     | no         |\n| kerberos    | no             | yes                       | yes                    | yes        |\n| ntlm        | yes            | yes                       | no                     | yes        |\n| credssp     | yes            | yes                       | yes                    | yes        |\n\nFor more information see the [Ansible CredSSP documentation](https://docs.ansible.com/ansible-core/2.18/os_guide/windows_winrm.html#credssp).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fterraform-libvirt-ansible-windows-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgl%2Fterraform-libvirt-ansible-windows-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fterraform-libvirt-ansible-windows-example/lists"}