Issue 1:
ISSUE TYPE

Feature Idea

Bug Report

COMPONENT NAME

with_dict

ANSIBLE VERSION

ansible --version
ansible 2.1.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

N/A

OS / ENVIRONMENT

Running Ansible from: Arch Linux

Target Host: Centos 7, Arch Linux

SUMMARY

When passing a dictionary via with_dict in a task and using certain portions of it to create values of another dictionary variable, nulls are not being preserved and incorrectly passed as empty string ""

STEPS TO REPRODUCE

- hosts: localhost
gather_facts: no
vars:
# defaults (for single nodes)
param1: "defaultParam1"
param2: ~
param3: ""
param4: []

# overrides (for multiple nodes)
nodes:
node1:
config_path: /tmp/node1.conf
config_overrides:
param1: "node1Param1"
param2: ~
param3: ""
param4: []
node2:
config_path: /tmp/node2.conf
config_overrides:

# dictionaries to be converted to json in config
single_node_config:
Param1: "{{ param1 }}"
Param2: "{{ param2 }}"
Param3: "{{ param3 }}"
Param4: "{{ param4 }}"

multi_node_config:
Param1: "{{ item.value.config_overrides.param1 | default(param1) }}"
Param2: "{{ item.value.config_overrides.param2 | default(param2) }}"
Param3: "{{ item.value.config_overrides.param3 | default(param3) }}"
Param4: "{{ item.value.config_overrides.param4 | default(param4) }}"

# toggle
enable_multi_nodes: false
tasks:
# task for single node
- name: create config
copy:
content: "{{ single_node_config | to_nice_json }}"
dest: /tmp/single.conf
when: enable_multi_nodes != true

# task multi nodes
- name: create configs
copy:
content: "{{ multi_node_config | to_nice_json }}"
dest: "{{ item.value.config_path }}"
with_dict: "{{ nodes }}"
when: enable_multi_nodes == true

EXPECTED RESULTS

cat /tmp/single.conf /tmp/node1.conf /tmp/node2.conf
{
"Param1": "defaultParam1",
"Param2": null,
"Param3": "",
"Param4": []
}
{
"Param1": "node1Param1",
"Param2": null,
"Param3": "",
"Param4": []
}
{
"Param1": "defaultParam1",
"Param2": null,
"Param3": "",
"Param4": []
}

ACTUAL RESULTS

cat /tmp/single.conf /tmp/node1.conf /tmp/node2.conf
{
"Param1": "defaultParam1",
"Param2": null,
"Param3": "",
"Param4": []
}
{
"Param1": "node1Param1",
"Param2": "",
"Param3": "",
"Param4": []
}
{
"Param1": "defaultParam1",
"Param2": "",
"Param3": "",
"Param4": []
}

Issue 2:
SUMMARY

None becomes "" when assigned to variable.

A comparison between a variable and what was assigned to it will return false.

Ran into this while using lookup('file', '/nonexistent', errors='ignore') - had to change a when: condition depending on whether comparing the lookup, or a variable with the lookup result.

ISSUE TYPE

Bug Report

COMPONENT NAME

core

ANSIBLE VERSION

ansible 2.7.0.dev0
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/foo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.5 (default, May 11 2018, 04:00:52) [GCC 8.1.0]

CONFIGURATION

OS / ENVIRONMENT

N/A

STEPS TO REPRODUCE

- set_fact:
foo: "{{ None }}"
- debug:
msg: "{{ foo == None }}"
- debug:
msg: "{{ foo == '' }}"

EXPECTED RESULTS

true, false

ACTUAL RESULTS

false, true

TASK [debug] **********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": false
}

TASK [debug] **********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": true
}