Trouble Updating VMware Custom Attributes with Ansible

17 views
Skip to first unread message

OOS

unread,
Apr 27, 2020, 10:39:52 AM4/27/20
to Ansible Project
Hi,

I'm trying to update custom attributes for existing VMware VMs using Ansible.  I spent quite a bit of time testing, but I can't seem to get it working.

---


- hosts: vcenter_hosts

  gather_facts: False

  connection: local


  vars_files:

    - ./vars/jg_vars_file.yml


  tasks:

- name: "Add multiple virtual machine custom attributes"

  vmware_guest_custom_attributes:

    hostname: "{{ hostname }}"

    username: "{{ username }}"

    password: "{{ password }}"

    moid: My-VM-Name

    state: present

    attributes:

      - name: creator

        value: "Me"

      - name: purpose

        value: "DEV VM"

  delegate_to: localhost

  register: attributes

Am I missing something or should this work?


ERROR! 'delegate_to' is not a valid attribute for a Play


The error appears to be in '/home/ansible/create-vm-attributes.yml': line 28, column 3, but may

be elsewhere in the file depending on the exact syntax problem.


The offending line appears to be:



- name: "Add multiple virtual machine custom attributes"

  ^ here


Thanks

Stefan Hornburg (Racke)

unread,
Apr 27, 2020, 10:46:00 AM4/27/20
to ansible...@googlegroups.com
On 4/27/20 4:39 PM, OOS wrote:
> Hi,
>
> I'm trying to update custom attributes for existing VMware VMs using Ansible.  I spent quite a bit of time testing, but
> I can't seem to get it working.
>
> /---/

Looks like your indentation is wrong, hence this error:

ERROR! 'delegate_to' is not a valid attribute for a Play

Regards
Racke

>
> /
> /
>
> /- hosts: vcenter_hosts/
>
> /  gather_facts: False/
>
> /  connection: local/
>
> /
> /
>
> /  vars_files:/
>
> /    - ./vars/jg_vars_file.yml/
>
> /
> /
>
> /  tasks:/
>
> /- name: "Add multiple virtual machine custom attributes"/
>
> /  vmware_guest_custom_attributes:/
>
> /    hostname: "{{ hostname }}"/
>
> /    username: "{{ username }}"/
>
> /    password: "{{ password }}"/
>
> /    moid: My-VM-Name/
>
> /    state: present/
>
> /    attributes:/
>
> /      - name: creator/
>
> /        value: "Me"/
>
> /      - name: purpose/
>
> /        value: "DEV VM"/
>
> /  delegate_to: localhost/
>
> /  register: attributes/
>
> Am I missing something or should this work?
>
>
> ERROR! 'delegate_to' is not a valid attribute for a Play
>
>
> The error appears to be in '/home/ansible/create-vm-attributes.yml': line 28, column 3, but may
>
> be elsewhere in the file depending on the exact syntax problem.
>
>
> The offending line appears to be:
>
>
>
> - name: "Add multiple virtual machine custom attributes"
>
>   ^ here
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5e44f38c-4a5b-4845-b1ae-2c1862400a8e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/5e44f38c-4a5b-4845-b1ae-2c1862400a8e%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages