Issue 1:
Hello I have the below task and fails with "You cannot call a method on a null-valued expression." only when parameter "force" is specified. The "KIT" directory is already created.

Ansible version is 2.0.0.2 on CentOS 6.7. The target operating system is Windows Server 2012 R2.

name: Download kit

win_get_url:

force: no

url: 'http://some_random_url/some_random_program.exe'

dest: 'C:\KIT\some_random_program.exe'

Thanks!

Issue 2:
Issue Type:

Feature Idea

COMPONENT NAME

core

Ansible Version:

$ ansible --version
ansible 2.0.0.2
config file =
configured module search path = Default w/o overrides

Ansible Configuration:

No custom configuration.

Environment:

Ubuntu 15.04

Summary:

When using shell module with attribute environment defined as {{provided_env|default(omit)}}, the attribute is not omitted and it fails with error "ERROR! environment must be a dictionary, received __omit_place_holder__dd43d6f3183f203e2d5011d3fe7f9d265a37ba74 (<type 'unicode'>)"

Steps To Reproduce:

- hosts: localhost
vars:
my_env:
ENV_VAR: "my env var"
tasks:
- name: test with valid env
shell: echo $ENV_VAR
environment:
ENV_VAR: "my env var"
register: result
- debug: var=result.stdout

- name: test with valid env
shell: echo $ENV_VAR
environment: "{{my_env}}"
register: result
- debug: var=result.stdout

- name: test with no env
shell: echo $ENV_VAR
register: result
- debug: var=result.stdout

- name: test with missing env default empty
shell: echo $ENV_VAR
environment: "{{unknown_env|default({})}}"
register: result
- debug: var=result.stdout

# Fails with message "ERROR! environment must be a dictionary, received __omit_place_holder__dd43d6f3183f203e2d5011d3fe7f9d265a37ba74 (<type 'unicode'>)"
- name: test with missing env default omit
shell: echo $ENV_VAR
environment: "{{unknown_env|default(omit)}}"
register: result
- debug: var=result.stdout

# Would fail with message "ERROR! 'unknown_env' is undefined" (or better "environment must be a dictionary, received {{unknown_env}}" in ansible 1.9.4)
- name: test with missing env
shell: echo $ENV_VAR
environment: "{{unknown_env}}"
register: result
- debug: var=result.stdout

Expected Results:

environment is simply omitted.

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [test with valid env] *****************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": "my env var"
}

TASK [test with valid env] *****************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": "my env var"
}

TASK [test with no env] ********************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

TASK [test with missing env default empty] *************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

TASK [test with missing env default omit] **************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

TASK [test with missing env] ***************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

PLAY RECAP *********************************************************************
localhost : ok=13 changed=6 unreachable=0 failed=0

Actual Results:

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [test with valid env] *****************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": "my env var"
}

TASK [test with valid env] *****************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": "my env var"
}

TASK [test with no env] ********************************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

TASK [test with missing env default empty] *************************************
changed: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] => {
"result.stdout": ""
}

TASK [test with missing env default omit] **************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! environment must be a dictionary, received __omit_place_holder__853b09b8abd224611d49aeb565bc95ac972fd575 (<type 'unicode'>)"}

PLAY RECAP *********************************************************************
localhost : ok=9 changed=4 unreachable=0 failed=1