Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: Error with args form. #13518

Closed
lberruti opened this issue Dec 11, 2015 · 3 comments
Closed

V2: Error with args form. #13518

lberruti opened this issue Dec 11, 2015 · 3 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@lberruti
Copy link
Contributor

Issue Type:

Bug Report

Ansible Version:

devel
ansible-playbook 2.1.0 (detached HEAD e56efa4) last updated 2015/12/11 17:08:24 (GMT +200)
lib/ansible/modules/core: (detached HEAD 0d23b3d) last updated 2015/12/11 17:08:46 (GMT +200)
lib/ansible/modules/extras: (detached HEAD 51813e0) last updated 2015/12/11 17:08:46 (GMT +200)
config file =
configured module search path = Default w/o overrides

Ansible Configuration:

none

Environment:

Debian 7

Steps To Reproduce:

ansible-playbook args1.yml ; ansible-playbook args2.yml ; ansible-playbook args3.yml

==> args1.yml <==

---
- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - file:
      args:
        path: /tmp/1
        state: directory
        mode: 755

==> args2.yml <==

---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
    my_dir:
      path: /tmp/2
      state: directory
      mode: 755
  tasks:
    - file:
      args: my_dir

==> args3.yml <==

---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
    my_dirs:
      - { path: /tmp/3a, state: directory, mode: 755 }
      - { path: /tmp/3b, state: directory, mode: 700 }
  tasks:
    - file:
      args: item
      with_items: my_dirs
Expected Results:
PLAY [localhost] **************************************************************

TASK: [file ] *****************************************************************
changed: [localhost]

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

PLAY [localhost] **************************************************************

TASK: [file ] *****************************************************************
changed: [localhost]

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

PLAY [localhost] **************************************************************

TASK: [file ] *****************************************************************
changed: [localhost] => (item={'path': '/tmp/3a', 'state': 'directory', 'mode': 755})
changed: [localhost] => (item={'path': '/tmp/3b', 'state': 'directory', 'mode': 700})

PLAY RECAP ********************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0
Actual Results:
PLAY ***************************************************************************

TASK [file path=/tmp/1 state=directory mode=755] *******************************
changed: [localhost]

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

Unexpected Exception: dictionary update sequence element #0 has length 1; 2 is required
to see the full traceback, use -vvv
Unexpected Exception: dictionary update sequence element #0 has length 1; 2 is required
to see the full traceback, use -vvv
Notes:

Same results with:

    - file:
      args: '{{my_dir}}'
@sivel
Copy link
Member

sivel commented Dec 11, 2015

Can you provide the "full traceback" as mentioned in the error via the use of -vvv to increase verbosity on the ansible-playbook command?

@lberruti
Copy link
Contributor Author

Hi @sivel,

No config file found; using defaults
Unexpected Exception: dictionary update sequence element #0 has length 1; 2 is required
the full traceback was:

Traceback (most recent call last):
  File "/Users/nemo/Works/ansible/bin/ansible-playbook", line 84, in <module>
    sys.exit(cli.run())
  File "/Users/nemo/Works/ansible/lib/ansible/cli/playbook.py", line 149, in run
    results = pbex.run()
  File "/Users/nemo/Works/ansible/lib/ansible/executor/playbook_executor.py", line 79, in run
    pb = Playbook.load(playbook_path, variable_manager=self._variable_manager, loader=self._loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/__init__.py", line 52, in load
    pb._load_playbook_data(file_name=file_name, variable_manager=variable_manager)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/__init__.py", line 92, in _load_playbook_data
    entry_obj = Play.load(entry, variable_manager=variable_manager, loader=self._loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/play.py", line 109, in load
    return p.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/base.py", line 200, in load_data
    self._attributes[name] = method(name, ds[name])
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/play.py", line 161, in _load_tasks
    return load_list_of_blocks(ds=ds, play=self, variable_manager=self._variable_manager, loader=self._loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/helpers.py", line 50, in load_list_of_blocks
    loader=loader
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/block.py", line 75, in load
    return b.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/base.py", line 200, in load_data
    self._attributes[name] = method(name, ds[name])
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/block.py", line 111, in _load_block
    use_handlers=self._use_handlers,
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/helpers.py", line 97, in load_list_of_tasks
    t = Task.load(task, block=block, role=role, task_include=task_include, variable_manager=variable_manager, loader=loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/task.py", line 133, in load
    return t.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/base.py", line 189, in load_data
    ds = self.preprocess_data(ds)
  File "/Users/nemo/Works/ansible/lib/ansible/playbook/task.py", line 172, in preprocess_data
    (action, args, delegate_to) = args_parser.parse()
  File "/Users/nemo/Works/ansible/lib/ansible/parsing/mod_args.py", line 281, in parse
    action, args = self._normalize_parameters(value, action=action, additional_args=additional_args)
  File "/Users/nemo/Works/ansible/lib/ansible/parsing/mod_args.py", line 140, in _normalize_parameters
    final_args.update(additional_args)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

@jimi-c jimi-c added this to the v2 milestone Dec 14, 2015
bcoca added a commit that referenced this issue Dec 16, 2015
They should already be templated before hitting this point?
otherwise the class needs the task variables passed into it.
relates to #13518 and  https://groups.google.com/forum/#!msg/ansible-project/esoBcphHwHs/Ghgi_M-MCQAJ
jimi-c added a commit that referenced this issue Dec 16, 2015
Also updates the CHANGELOG to note the slight change, where bare variables
in args are no longer allowed to be bare variables

Fixes #13518
@jimi-c jimi-c closed this as completed in 8716bf8 Dec 16, 2015
@jimi-c
Copy link
Member

jimi-c commented Dec 16, 2015

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants