Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

vmware_guest

ANSIBLE VERSION

ansible --version
ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

CONFIGURATION

Standard ansible config, no changes

OS / ENVIRONMENT

cat /etc/lsb-release

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=16.04

DISTRIB_CODENAME=xenial

DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"

SUMMARY

Following the example given in https://docs.ansible.com/ansible/vmware_guest_module.html, Create a VM from a template, I tried to add an extra disk while creating a VM from template. It throws an error.

STEPS TO REPRODUCE

I tried to use a template to create a VM . The template is a RHEL 7, 64bit one, with 40GB HDD attached and partitioned via LVM. The code used is given below .

- name: deploy virtual machine from template
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ vm_name }}"
validate_certs: "false"
cluster: "{{ vcenter_cluster }}"
datacenter: "{{ vcenter_datacenter }}"
folder: "/dev/VMs"
state: poweredon
#guest_id: rhel7Guest
disk:
- size_gb: 40
type: thin
datastore: "{{ datastore }}"
# autoselect_datastore: True
- size_gb: 150
type: thin
datastore: "{{ datastore }}"
#autoselect_datastore: True
hardware:
memory_mb: "4096"
num_cpus: "2"
scsi: paravirtual
networks:
- name: "{{ vm-vlan }}"
ip: 192.168.051
netmask: 255.255.255.0
template: "{{ vm_template }}"
delegate_to: "localhost"
register: "deploy"

EXPECTED RESULTS

Expected to create a VM with 2 HDDs, 40GB and 150GB HDDs

ACTUAL RESULTS

Fails. with error

fatal: [localhost -> localhost]: FAILED! => {"changed": true, "failed": true, "msg": "A specified parameter was not correct: spec.location.host"}

If I omit the disk option and its variables, the VM is created with the default 40GB HDD and in the same datastore where the template is stored.

Issue 2:
From @X-Cli on 2015-08-15T16:56:46Z

ISSUE TYPE

Bug Report

COMPONENT NAME

lxc_container module

ANSIBLE VERSION

container_config is parsed as a python dict by the ansible lxc_container module, at least in current stable version 1.9.

SUMMARY

container_config is parsed as a Python dict by the ansible lxc_container module, at least in current stable version 1.9.

https://github.com/ansible/ansible-modules-extras/blob/stable-1.9/cloud/lxc/lxc_container.py

Lines 1442 to 1444 :

container_config=dict(
type='str'
),

Python dict are unordered, which may lead to corrupted config files. For instance, config directives for LXC network follow a specific order, which is overlooked by the module when the config file is written on disk.

As such, the following playbook excerpt

tasks:
- include_vars: ../vars/lxc_config.yml
- include_vars: ../globals.yml
- name: "Create LXC"
become: yes
become_method: sudo
lxc_container:
name: "{{ lxc_name }}"
state: stopped
lxc_path: /var/lib/lxc
template: ubuntu
container_config:
- "lxc.network.type = veth"
- "lxc.network.name = internet"
- "lxc.network.ipv4 = {{ internet_ip }}"
- "lxc.network.link = internet_br"
- "lxc.network.flags = up"
- "lxc.network.type = veth"
- "lxc.network.name = local"
- "lxc.network.ipv4 = {{ local_ip }}"
- "lxc.network.link = local_br"
- "lxc.network.flags = up"
- "lxc.network.type = veth"
- "lxc.network.name = admin"
- "lxc.network.ipv4 = {{ admin_ip }}"
- "lxc.network.ipv4.gateway = {{ admin_gateway }}"
- "lxc.network.link = admin_br"
- "lxc.network.flags = up"

results in the following broken LXC config file

# Network configuration
lxc.network.type = veth
lxc.network.type = veth
lxc.network.flags = up
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.link = admin_br
lxc.network.link = local_br
lxc.network.link = internet_br
lxc.network.hwaddr = 00:16:3e:f1:f5:8e
lxc.network.name = internet
lxc.network.name = admin
lxc.network.name = local
lxc.network.ipv4 = 172.31.0.1
lxc.network.ipv4 = 192.168.0.1
lxc.network.ipv4 = 10.0.0.1
lxc.network.ipv4.gateway = 192.168.0.254

As you can see, parsing in a dict also deduplicates some crucial config lines, which have to be duplicated in a valid LXC config file.

Being completely new to Ansible (this was my very first playbook sigh), I am not sure if there is a workaround (except maybe using a templated config file and avoiding container_config altogether). Still, if the container_config could be handled as an ordered YAML sequence, I believe this could solve the problem.

Thank you.

Copied from original issue: ansible/ansible-modules-extras#836