{"id":20165842,"url":"https://github.com/duffney/ansible-azure-samples","last_synced_at":"2026-03-07T06:02:32.456Z","repository":{"id":82666059,"uuid":"333487563","full_name":"duffney/ansible-azure-samples","owner":"duffney","description":"Sample Ansible playbooks for deploying and managing Azure resources.","archived":false,"fork":false,"pushed_at":"2021-05-06T15:06:09.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-01T06:34:18.795Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","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/duffney.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-27T16:18:39.000Z","updated_at":"2021-07-22T08:05:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"726a66c5-840c-4135-bada-527bd5b583cb","html_url":"https://github.com/duffney/ansible-azure-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/duffney/ansible-azure-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffney%2Fansible-azure-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffney%2Fansible-azure-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffney%2Fansible-azure-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffney%2Fansible-azure-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duffney","download_url":"https://codeload.github.com/duffney/ansible-azure-samples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffney%2Fansible-azure-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30208801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-14T00:39:18.183Z","updated_at":"2026-03-07T06:02:32.401Z","avatar_url":"https://github.com/duffney.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-on-azure\n\nSample Ansible playbooks for deploying and managing Azure resources.\n\n## Prerequisites\n\n* [Docker Desktop]()\n* [PowerShell]() + [Azure PowerShell]() OR [AzCLI]()\n\n## 1. Create an Azure AD Service Principal\n\n### PowerShell\n\n1. Create the Azure AD Service Principal Account\n\n    ```powershell\n    $password = '\u003cPassword\u003e'\n\n    $credentials = New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential `\n    -Property @{ StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password=$password}\n\n    $spSplat = @{\n      DisplayName = 'ansible'\n      PasswordCredential = $credentials\n    }\n\n    $sp = New-AzAdServicePrincipal @spSplat\n    ```\n\n    Replace `\u003cPassword\u003e` with your password.\n\n2. Assign the Contributor Role to the Service Principal\n\n    ```powershell\n    $subId = (Get-AzContext).Subscription.Id\n    \n    $roleAssignmentSplat = @{\n      ObjectId = $sp.id;\n      RoleDefinitionName = 'Contributor';\n      Scope = \"/subscriptions/$subId\"\n    }\n    \n    New-AzRoleAssignment @roleAssignmentSplat\n    ```\n\n    \u003e NOTE: To improve security, change the scope of the role assignment to a resource group instead of a subscription.\n\n### AzCLI\n\n```azurecli\n\n```\n\n## 2. Build the Ansible Container\n\n**Build the Ansible container image.**\n\nChange to the `\\ansible-container\\$version` directory, `$version` represents the version of Ansible you want to run.\n\n```powershell\ndocker build . -t ansible\n```\n\n## 3. Run the Ansible Container\n\n### Output the required Azure AD Service Principal information\n\n```powershell\n@{\n    subscriptionId = (Get-AzContext).Subscription.Id\n    clientid = (Get-AzADServicePrincipal -DisplayName 'ansible').ApplicationId.Guid\n    tenantid = (Get-AzContext).Tenant.Id\n}\n```\n\n### Run the Container\n\nWindows\n\n```powershell\ndocker run -it --rm --volume ${PWD}:/ansible --workdir /ansible `\n--env \"AZURE_SUBSCRIPTION_ID=\u003cAzure_Subscription_ID\u003e\" `\n--env \"AZURE_CLIENT_ID=\u003cService_Principal_Application_ID\u003e\" `\n--env \"AZURE_SECRET=\u003cService_Principal_Password\u003e\" `\n--env \"AZURE_TENANT=\u003cAzure_Tenant\u003e\" `\nansible\n```\n\nLinux\n\n```bash\ndocker run -it --rm --volume \"$(pwd):/ansible\" --workdir /ansible \\\n--env \"AZURE_SUBSCRIPTION_ID=\u003cAzure_Subscription_ID\u003e\" \\\n--env \"AZURE_CLIENT_ID=\u003cService_Principal_Application_ID\u003e\" \\\n--env \"AZURE_SECRET=\u003cService_Principal_Password\u003e\" \\\n--env \"AZURE_TENANT=\u003cAzure_Tenant\u003e\" \\\nansible\n```\n\nReplace `\u003cValues\u003e` with the information output in step 3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduffney%2Fansible-azure-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduffney%2Fansible-azure-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduffney%2Fansible-azure-samples/lists"}