{"id":24492,"date":"2021-04-17T01:45:13","date_gmt":"2021-04-17T01:45:13","guid":{"rendered":"http:\/\/matthewjrodgers.com\/?p=24492"},"modified":"2021-04-17T01:45:15","modified_gmt":"2021-04-17T01:45:15","slug":"microsoft-azure-create-resources-using-ansible","status":"publish","type":"post","link":"https:\/\/matthewjrodgers.com\/?p=24492","title":{"rendered":"Microsoft Azure: create resources using Ansible"},"content":{"rendered":"\n<p>Using\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/developer\/ansible\/vm-configure?tabs=ansible\" target=\"_blank\">this<\/a>\u00a0walkthrough, I use Ansible to create resources in my Microsoft Azure account. I then use Ansible to create a virtual machine within that environment. I\u2019m running Ansible on my localhost within the Windows Subsystem for Linux. This page gives an outline and then showcases parts of this project. You can find the Ansible files used in this project\u00a0<a href=\"https:\/\/github.com\/matthewjrodgers\/Ansible-create-infrastructure-GitHub-public-repo-version\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<ol><li>Create a resource group<\/li><li>Create a virtual network<ul><li>Create a subnet within the virtual network<\/li><\/ul><\/li><li>Create a public IP address<\/li><li>Create a network security group<\/li><li>Create a virtual network interface card<\/li><li>Create a storage account<\/li><li>Create a virtual machine<\/li><li>Interactively SSH into the virtual machine using Azure Cloud Shell<\/li><li>Deallocate virtual machine<\/li><\/ol>\n\n\n\n<p>The following excerpts are shown below:<\/p>\n\n\n\n<ol><li>The entire contents of the file that creates a network security group<\/li><li>Interactive SSH session with the virtual machine<\/li><li>Details about the virtual machine as seen in the Azure portal<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>---\r\n\r\n# creates a network security group in Azure\r\n\r\n- hosts: localhost\r\n  connection: local\r\n  tasks:\r\n    - name: Create Network Security Group - {{ name }} in Resource Group - {{ ResourceGroup }} that allows SSH\r\n      azure_rm_securitygroup:\r\n        resource_group: \"{{ ResourceGroup }}\"\r\n        name: \"{{ name }}\"\r\n        rules:\r\n          - name: SSH\r\n            description: Allow SSH traffic on TCP port 22\r\n            protocol: Tcp\r\n            destination_port_range: 22\r\n            access: Allow\r\n            priority: 1001\r\n            direction: Inbound\r\n      register: nsg\r\n    - debug:\r\n        var: nsg<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"587\" src=\"https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-1024x587.png\" alt=\"\" class=\"wp-image-24493\" srcset=\"https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-1024x587.png 1024w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-300x172.png 300w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-768x441.png 768w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-1536x881.png 1536w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-982x563.png 982w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred-400x229.png 400w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-cli-vm-ssh-screenshot-sensitive-content-blurred.png 1590w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"990\" height=\"1024\" src=\"https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-990x1024.png\" alt=\"\" class=\"wp-image-24494\" srcset=\"https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-990x1024.png 990w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-290x300.png 290w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-768x794.png 768w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-982x1015.png 982w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred-387x400.png 387w, https:\/\/matthewjrodgers.com\/wp-content\/uploads\/2021\/04\/azure-portal-vm-sensitive-info-blurred.png 999w\" sizes=\"(max-width: 990px) 100vw, 990px\" \/><\/figure>\n\n\n\n<p>And that&#8217;s it for this post! Thank you for reading!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using\u00a0this\u00a0walkthrough, I use Ansible to create resources in my Microsoft Azure account. I then use Ansible to create a virtual machine within that environment. I\u2019m running Ansible on my localhost within the Windows Subsystem for Linux. This page gives an outline and then showcases parts of this project. You can find the Ansible files used&hellip; <a href=\"https:\/\/matthewjrodgers.com\/?p=24492\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Microsoft Azure: create resources using Ansible<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[5,4],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/posts\/24492"}],"collection":[{"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24492"}],"version-history":[{"count":1,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/posts\/24492\/revisions"}],"predecessor-version":[{"id":24495,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=\/wp\/v2\/posts\/24492\/revisions\/24495"}],"wp:attachment":[{"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matthewjrodgers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}