Issue 1:
ISSUE TYPE

Bug Report

Documentation Report

COMPONENT NAME

vmware_guest

ANSIBLE VERSION

$ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)]

CONFIGURATION

[defaults]
host_key_checking = false
callback_plugins = callback
inventory = ../inventory/infra
roles_path = ../roles
retry_files_enabled = False

OS / ENVIRONMENT

Linux mymachine 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

SUMMARY

The VM is created every time I launch the playbook. So finally we have a duplication of the VM.

STEPS TO REPRODUCE

Fill the following task for a play as "connection:local" and play it to connect to a vCenter in 5.5.0

- name: Create VMs for templates
vmware_guest:
hostname: "{{ vsphere_server }}" #vmware
username: "{{ user }}" #vmware
password: "{{password }}" #vmware
validate_certs: no
cluster: "{{ machine.cluster }}"
datacenter: "{{ machine.datacenter }}"
name: "{{ machine.name }}" #seen in the vsphere hostname
name_match: first # supposed to prevent duplicated vm
template: "{{ template_windows if machine.os == 'windows' else template_linux }}"
hardware:
memory_mb: "{{ machine.memory }}"
num_cpus: "{{ machine.vcpu }}"
networks : "{{machine.iplist}}"
disk: "{{machine.vdisks}}"
state: poweredon

EXPECTED RESULTS

When you play it several times, a new VM is created each time instead of using the one previously created, finally you get a duplicated VM

ACTUAL RESULTS

Duplicated VM

TASK [generateMachine : Create VMs for templates] ***************************************************************************************************************
task path: /root/3-quickVm_management/roles/generateMachine/tasks/linux.yml:3
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258 `" && echo ansible-tmp-1510160462.81-92627317344258="` echo /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpgQsSZr TO /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258/vmware_guest.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258/ /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258/vmware_guest.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258/vmware_guest.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1510160462.81-92627317344258/" > /dev/null 2>&1 && sleep 0'
changed: [127.0.0.1] => {
"changed": true,
"failed": false,
"instance": {
"annotation": "",
"current_snapshot": null,
"customvalues": {},
"guest_tools_status": "guestToolsNotRunning",
"guest_tools_version": "10249",
"hw_eth0": {
"addresstype": "assigned",
"ipaddresses": null,
"label": "Network adaptor 1",
"macaddress": "00:50:56:94:07:93",
"macaddress_dash": "00-50-56-94-07-93",
"summary": "DVSwitch : 91 3f 14 50 7d 79 85 56-59 4d 79 63 62 a3 3f 23"
},
"hw_guest_full_name": null,
"hw_guest_id": null,
"hw_interfaces": [
"eth0"
],
"hw_memtotal_mb": 8192,
"hw_name": "myVm",
"hw_power_status": "poweredOn",
"hw_processor_count": 2,
"hw_product_uuid": "4214102c-be1d-4d67-04ee-8b9d116343ef",
"ipv4": null,
"ipv6": null,
"module_hw": true,
"snapshots": []
},
"invocation": {
"module_args": {
"annotation": null,
"cluster": "myCluster",
"customization": {},
"customvalues": [],
"datacenter": "myDatacenter",
"disk": [
{
"datastore": "MyDatastore",
"size_gb": 40,
"type": "thin"
},
{
"datastore": "MyDatastore",
"size_gb": 10,
"type": "thin"
}
],
"esxi_hostname": null,
"folder": "/vm",
"force": false,
"guest_id": null,
"hardware": {
"memory_mb": "8192",
"num_cpus": "2"
},
"hostname": "192.168.204.40",
"is_template": false,
"name": "myVm",
"name_match": "first",
"networks": [
{
"gateway": "192.168.204.1",
"ip": "192.168.204.148",
"name": "myNetwork",
"netmask": "255.255.255.0"
}
],
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"resource_pool": null,
"state": "poweredon",
"template": "myTemplate",
"template_src": "myTemplate",
"username": "XXXXXXXXX",
"uuid": null,
"validate_certs": false,
"wait_for_ip_address": false
}
}
}

Issue 2:
ISSUE TYPE

Bug Report

ANSIBLE VERSION

ansible 2.1.1.0
config file =
configured module search path = Default w/o overrides

CONFIGURATION

hosts file:

[localhost]

127.0.0.1

[localhost:vars]

ansible_connection=local

OS / ENVIRONMENT

UBUNTU 16.04 LTS

SUMMARY

Running a playbook with inventory file which have group of 127.0.0.1 and also with localhost as a host cause the playbook to be executed as if we have 2 hosts, but the commands actually runs on the same host, and can be faulty depends on the tasks.

STEPS TO REPRODUCE

command:

ansible-playbook -i inventory/hosts playbook.yml

playbook:

- hosts: localhost
connection: local
tasks:
- foo

EXPECTED RESULTS

==> default: TASK [setup] *******************************************************************

==> default: ok: [127.0.0.1]

==> default:

==> default: TASK [foo] *****************************************************

==> default: ok: [127.0.0.1 -> localhost]

ACTUAL RESULTS

==> default: TASK [setup] *******************************************************************

==> default: ok: [127.0.0.1]

==> default: ok: [localhost]

==> default:

==> default: TASK [foo] *****************************************************

==> default: ok: [localhost -> localhost]

==> default: ok: [127.0.0.1 -> localhost]

I could bypass this issue by changing my command to:

ansible-playbook -i localhost, playbook.yml