Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

src parameter doesn't work as expected when using the FQCN of the k8s module #341

Closed
romogo17 opened this issue Jan 9, 2021 · 2 comments
Labels
needs_info More information required in order to debug the issue such as console log, library versions etc.

Comments

@romogo17
Copy link

romogo17 commented Jan 9, 2021

SUMMARY

When using the FQCN of the k8s module with the src parameter, the module fails to find or access the referenced file

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [kube-instance-singlenode]: FAILED! => changed=false 
  msg: |-
    Could not find or access '/tmp/calico.yaml' on the Ansible Controller.
    If you are using a module and expect the file to exist on the remote, see the remote_src option
ISSUE TYPE
  • Bug Report
COMPONENT NAME

k8s

ANSIBLE VERSION
ansible 2.10.4
  config file = /Users/ro/Dev/kubernetes-fundamentals/ansible.cfg
  configured module search path = ['/Users/ro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.10.4/libexec/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.1 (default, Dec 28 2020, 11:24:06) [Clang 12.0.0 (clang-1200.0.32.28)]
CONFIGURATION
DEFAULT_LOAD_CALLBACK_PLUGINS(/Users/ro/Dev/k8s-lab/ansible.cfg) = True
DEFAULT_ROLES_PATH(/Users/ro/Dev/k8s-lab/ansible.cfg) = ['/Users/ro/Dev/k8s-lab/roles']
DEFAULT_STDOUT_CALLBACK(/Users/ro/Dev/k8s-lab/ansible.cfg) = yaml
HOST_KEY_CHECKING(/Users/ro/Dev/k8s-lab/ansible.cfg) = False
INVENTORY_ENABLED(/Users/ro/Dev/k8s-lab/ansible.cfg) = ['gcp_compute']
OS / ENVIRONMENT

Controller

  • OS: Mac OS X
  • Version: 10.15.7

Remote

  • CentOS Linux release 8.3.2011
STEPS TO REPRODUCE

To reproduce, use the module with the FQCN using the src parameter on a file in the remote host

- hosts: all
  tasks:
    - name: Download the calico manifest
      ansible.builtin.get_url:
        url: "https://docs.projectcalico.org/manifests/calico.yaml"
        dest: "/tmp"
    - name: Apply the calico manifests
      community.kubernetes.k8s:
        src: "/tmp/calico.yaml"
EXPECTED RESULTS
PLAY [all] ***********************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************
ok: [kube-instance-singlenode]

TASK [Download the calico manifest] **********************************************************************************************************************************
ok: [kube-instance-singlenode]

TASK [Apply the calico manifests] ************************************************************************************************************************************
changed: [kube-instance-singlenode]

PLAY RECAP ***********************************************************************************************************************************************************
kube-instance-singlenode   : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

These results are obtained when using a playbook without the FQCN, such as

- hosts: all

  tasks:
    - name: Download the calico manifest
      ansible.builtin.get_url:
        url: "https://docs.projectcalico.org/manifests/calico.yaml"
        dest: "/tmp"
    - name: Apply the calico manifests
      k8s:
        src: "/tmp/calico.yaml"
ACTUAL RESULTS
PLAY [all] ***************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************
ok: [kube-instance-singlenode]

TASK [Download the calico manifest] **************************************************************************************
ok: [kube-instance-singlenode]

TASK [Apply the calico manifests] ****************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [kube-instance-singlenode]: FAILED! => changed=false 
  msg: |-
    Could not find or access '/tmp/calico.yaml' on the Ansible Controller.
    If you are using a module and expect the file to exist on the remote, see the remote_src option

PLAY RECAP ***************************************************************************************************************
kube-instance-singlenode   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
@tima
Copy link
Collaborator

tima commented Jan 13, 2021

@romogo17 I think this may be a duplicate of #307 and #333. Could you verify what version of this collection you are using here?

@tima tima added the needs_info More information required in order to debug the issue such as console log, library versions etc. label Jan 13, 2021
@romogo17
Copy link
Author

Hi @tima, I'm currently using v1.1.1

# /usr/local/Cellar/ansible/2.10.4/libexec/lib/python3.9/site-packages/ansible_collections
Collection           Version
-------------------- -------
community.kubernetes 1.1.1 

After reading #307 (and #320) I tried to install the collection directly from the main branch.

TEST

I used the playbook I was having issues with, and it worked fine with and without the FQCN

- hosts: all
  tasks:
    - name: Download the calico manifest
      ansible.builtin.get_url:
        url: "https://docs.projectcalico.org/manifests/calico.yaml"
        dest: "/tmp"
    - name: Apply the calico manifests
      community.kubernetes.k8s:
        src: "/tmp/calico.yaml"
- hosts: all
  tasks:
    - name: Download the calico manifest
      ansible.builtin.get_url:
        url: "https://docs.projectcalico.org/manifests/calico.yaml"
        dest: "/tmp"
    - name: Apply the calico manifests
      k8s:
        src: "/tmp/calico.yaml"
RESULTS
TASK [Download the calico manifest] *************************************************************************************
ok: [kube-instance-singlenode]

TASK [Apply the calico manifests] ***************************************************************************************
changed: [kube-instance-singlenode]

PLAY RECAP **************************************************************************************************************
kube-instance-singlenode   : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Thank you for pointing me into the right direction!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs_info More information required in order to debug the issue such as console log, library versions etc.
Projects
None yet
Development

No branches or pull requests

2 participants