Skip to content

Instantly share code, notes, and snippets.

@cetinerdev
Created August 10, 2021 19:41
Show Gist options
  • Save cetinerdev/dfe6ec2884dd2c7f312ff1ca7de344bd to your computer and use it in GitHub Desktop.
Save cetinerdev/dfe6ec2884dd2c7f312ff1ca7de344bd to your computer and use it in GitHub Desktop.

Revisions

  1. cetinerdev created this gist Aug 10, 2021.
    46 changes: 46 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    ❯ cat ansible.cfg
    [inventory]
    enable_plugins = vmware_vm_inventory

    ❯ cat inventory.vmware.yaml
    $ANSIBLE_VAULT;1.1;AES256
    61316164336134653239363839303162666261643730376233623333376235656533323435623162
    ...
    ...

    ❯ ansible-inventory -i inventory.vmware.yaml --graph --vault-password-file=~/.vault_pass
    @all:
    |--@fedora64Guest:
    | |--dhcp_4217fa4f-172a-7082-70e5-94a7097f3d43
    .....


    ❯ cat clusterinfo.yaml
    ---
    - name: cluster info
    hosts: localhost
    debugger: on_failed
    connection: local
    gather_facts: no
    tasks:
    - name: Gather cluster info from a given datacenter
    vmware_cluster_info:
    hostname: '{{ hostname }}'
    username: '{{ username }}'
    password: '{{ password }}'
    validate_certs: False
    datacenter: Datacenter01
    ❯ ansible-playbook -i inventory.vmware.yaml --vault-password-file=~/.vault_pass clusterinfo.yaml

    PLAY [cluster info] **********************************************************************

    TASK [Gather cluster info from a given datacenter] ***************************************
    fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'hostname' is undefined\n\nThe error appears to be in '/Users/ceto/Documents/creentech-zabbix/clusterinfo.yaml': line 8, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Gather cluster info from a given datacenter\n ^ here\n"}
    [localhost] TASK: Gather cluster info from a given datacenter (debug)> p task.args
    {'datacenter': 'Datacenter01',
    'hostname': '{{ hostname }}',
    'password': '{{ password }}',
    'username': '{{ username }}',
    'validate_certs': False}
    [localhost] TASK: Gather cluster info from a given datacenter (debug)>