Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.71 KB

ansible-snippet-create-resource-group.md

File metadata and controls

68 lines (55 loc) · 1.71 KB
author ms.service ms.topic ms.date ms.author
tomarchermsft
ansible
include
04/22/2019
tarcher
  1. In Cloud Shell, create a file named rg.yml.

    code rg.yml
  2. Paste the following code into the editor:

    ---
    - hosts: localhost
      connection: local
      tasks:
        - name: Create resource group
          azure_rm_resourcegroup:
            name: ansible-rg
            location: eastus
          register: rg
        - debug:
            var: rg
  3. Save the file and exit the editor.

  4. Run the playbook using the ansible-playbook command:

    ansible-playbook rg.yml

After running the playbook, you see output similar to the following results:

PLAY [localhost] *********************************************************************************

TASK [Gathering Facts] ***************************************************************************
ok: [localhost]

TASK [Create resource group] *********************************************************************
changed: [localhost]

TASK [debug] *************************************************************************************
ok: [localhost] => {
    "rg": {
        "changed": true,
        "contains_resources": false,
        "failed": false,
        "state": {
            "id": "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/ansible-rg",
            "location": "eastus",
            "name": "ansible-rg",
            "provisioning_state": "Succeeded",
            "tags": null
        }
    }
}

PLAY RECAP ***************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0