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

'delegate_to' is not a valid attribute for a TaskInclude #3985

Closed
richardsonlima opened this issue Jan 5, 2019 · 26 comments · Fixed by #4783
Closed

'delegate_to' is not a valid attribute for a TaskInclude #3985

richardsonlima opened this issue Jan 5, 2019 · 26 comments · Fixed by #4783

Comments

@richardsonlima
Copy link

**Is this a BUG REPORT:
Hey guys,

I believe that I found an issue related to delegate_to in this case it can't be combined with include_tasks anymore.

Environment:

  • Cloud provider or hardware configuration:
    Baremetal

  • OS (printf "$(uname -srm)\n$(cat /etc/os-release)\n"):
    Linux 4.16.3-301.fc28.x86_64 x86_64
    NAME=Fedora
    VERSION="28 (Workstation Edition)"
    ID=fedora
    VERSION_ID=28
    PLATFORM_ID="platform:f28"
    PRETTY_NAME="Fedora 28 (Workstation Edition)"
    ANSI_COLOR="0;34"
    CPE_NAME="cpe:/o:fedoraproject:fedora:28"
    HOME_URL="https://fedoraproject.org/"
    SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    REDHAT_BUGZILLA_PRODUCT="Fedora"
    REDHAT_BUGZILLA_PRODUCT_VERSION=28
    REDHAT_SUPPORT_PRODUCT="Fedora"
    REDHAT_SUPPORT_PRODUCT_VERSION=28
    PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
    VARIANT="Workstation Edition"
    VARIANT_ID=workstation

  • Version of Ansible (ansible --version):
    ansible 2.8.0.dev0
    config file = /home/richardson/git/kubespray/ansible.cfg
    configured module search path = [u'/home/richardson/git/kubespray/library']
    ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.8.0.dev0-py2.7.egg/ansible
    executable location = /usr/bin/ansible
    python version = 2.7.14 (default, Mar 14 2018, 16:45:33) [GCC 8.0.1 20180222 (Red Hat 8.0.1-0.16)]

Kubespray version (commit) (git rev-parse --short HEAD):
39d7503

Network plugin used:
calico

Command used to invoke ansible:
➜ ~ ansible-playbook -i ./inventory/tr-dev-spo-bra-cluster/hosts.ini --private-key="/home/richardson/.ssh/id_rsa" -e ansible_user=MY-USER --extra-vars "ansible_sudo_pass=MY-PASSWORD" cluster.yml --become -vvv

Output of ansible run:
https://gist.github.com/richardsonlima/7600f9aaa977311d07fb34f1f01f9c7f

@Sh4d1
Copy link
Member

Sh4d1 commented Mar 20, 2019

@mattymo any ideas on how to solve this?

@cwpenhale
Copy link

Hey, I'm running into this as well. I'm on the Ansible 2.8.0rc1 because I needed 'use_contrib_script_compatible_sanitization' fix for the GCP dynamic inventory plugin. Is this a known issue, are there other people running into this?

@rhockenbury
Copy link
Contributor

Hit this today w/ 2.8.0rc2. This is the expected beahavior of 2.8 according to this - ansible/ansible#56072

@electrocucaracha
Copy link
Contributor

electrocucaracha commented May 16, 2019

It seems like INVALID_TASK_ATTRIBUTE_FAILED default value has been changed to True. Maybe I quick workaround could be its default value until it's change in ansible.

export ANSIBLE_INVALID_TASK_ATTRIBUTE_FAILED=False

@rhockenbury
Copy link
Contributor

Yes, I believe I ended up setting that, but got hung up on a handful of other errors I encountered further along when using the 2.8 rc, and eventually gave up. Would be interested to hear if anyone has successfully deployed Kubespray with Ansible2.8

@electrocucaracha
Copy link
Contributor

electrocucaracha commented May 16, 2019

Yes, I believe I ended up setting that, but got hung up on a handful of other errors I encountered further along when using the 2.8 rc, and eventually gave up. Would be interested to hear if anyone has successfully deployed Kubespray with Ansible2.8

@rhockenbury I did it. I have submitted the PR to disable that feature, in the meantime you can use the workaround that I mentioned disabling ANSIBLE_INVALID_TASK_ATTRIBUTE_FAILED thru a environment variable.

@rhockenbury
Copy link
Contributor

I'm hitting this w/ ansible 2.8:

TASK [download : kubeadm | Copy kubeadm binary from download dir] *********************************************************************************************************************************************************
Friday 17 May 2019  14:50:55 -0400 (0:00:01.207)       0:05:40.951 ************
fatal: [ul-lin-mast-8k.uunet.arlington.predictivetechnologies.com]: FAILED! => {"changed": false, "cmd": "sshpass", "msg": "[Errno 2] No such file or directory", "rc": 2}

@electrocucaracha Did you run into this?

@electrocucaracha
Copy link
Contributor

@rhockenbury it seems like you're running kubespray in Ubuntu distro. What I do is to install sshpass before its execution.

@karthik101
Copy link

On some environments passing the variable didnt do any effect so i had to add the below in ansible.cfg file in kubespray folder.

[defaults]
invalid_task_attribute_failed=False

@woopstar
Copy link
Member

Ansible 2.8 is not supported yet

@houming818
Copy link

can I downgrade to any version of ansible?

@electrocucaracha
Copy link
Contributor

can I downgrade to any version of ansible?

@stduolc according to the documentation you should use v2.7.8

johnstudarus added a commit to equinix-labs/Rook-on-Bare-Metal-Workshop that referenced this issue Jul 14, 2019
@rushins
Copy link

rushins commented Oct 22, 2019

i hit the same error today

ERROR! 'delegate_to' is not a valid attribute for a TaskInclude

The error appears to be in '/root/kubespray/roles/network_plugin/calico/tasks/main.yml': line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • include_tasks: upgrade.yml

BR,
Rushi.

@nf123git
Copy link

nf123git commented Feb 11, 2020

The problem is this:

  1. I can use import_tasks with delegate_to
  2. I cannot use import_tasks with a loop - it says:
    You cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.
  3. I cannot use delegate_to, with include_tasks, because I hit this issue:
    'delegate_to' is not a valid attribute for a TaskInclude

So... once again, Ansible makes it impossible to do something that should be incredibly simple.

Found a workaround for 3. at least.
Just wrap the include_tasks in a block. and put the delegate at the block level.

e.g.

- include_tasks: inc.yml
  delegate_to: host1

change to:

- block:
    - include_tasks: inc.yml
  delegate_to: host1

@r-trigo
Copy link

r-trigo commented Mar 4, 2020

This post may help:

The solution, explained

Input:
We can not use loop with import, we need to use include.
We can not use delegate to with include, we need to use import.
Solution:
We use loop + include_tasks to run a separate tasklist.
2. We use import_role + delegate_to to delegate a role to another host.

@techcloudim
Copy link

This is expected behaviour in Ansible 2.8. ansible/ansible#56072

you need to follow below syntax

- name: Setting up xxxx
   include_tasks: xxxx.yml
   args:
     apply:
         delegate_to: 127.0.0.1
   with_items:
     - "{{ plugins_loop }}"
   run_once: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
13 participants