-
Notifications
You must be signed in to change notification settings - Fork 104
k8s module src options doesn't seems to work #307
Comments
@sylvainOL - One quick question: for the copy task, you're using the folded scalar option: content: >
apiVersion: apps/v1
Kind: Deployment
Metadata:
name: nginx-deployment
labels:
app: nginx That seems like it would result in an invalid file being copied into place, with contents like:
Can you try using the literal scalar instead, so newlines are preserved? content: |
apiVersion: apps/v1
Kind: Deployment
Metadata:
name: nginx-deployment
labels:
app: nginx |
Hi @geerlingguy, the file is OK when I look at it:
But I can make the test with |
results (with one ansible-playbook -i inventory /tmp/test.yaml -v PLAY [other] ************************************************************************************************************************************************************************************************************************************* TASK [Gathering Facts] *************************************************************************************************************************************************************************************************************************** TASK [generate k8s yaml] ************************************************************************************************************************************************************************************************************************* TASK [add deploy] ******************************************************************************************************************************************************************************************************************************** PLAY RECAP *************************************************************************************************************************************************************************************************************************************** |
|
so the behavior is the same than before And thanks for the quick reply! |
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@sylvainOL Could you please try #320 and the following playbook? ---
- hosts: centos
tasks:
- name: generate k8s yaml
copy:
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
dest: /tmp/deploy.yml
- name: add deploy
community.kubernetes.k8s:
state: present
remote_src: True
src: /tmp/deploy.yml |
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Either you can copy all the files from this PR to the respective location in community.kubernetes or
|
👍 , I'll do it asap |
this playbook worked with #320: ---
- hosts: other
gather_facts: False
tasks:
- name: generate k8s yaml
copy:
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
dest: /tmp/deploy.yml
- name: add deploy
community.kubernetes.k8s:
state: present
remote_src: True
src: /tmp/deploy.yml |
so #320 fixes one of the two issues (actually the one that I wanted ;) ) Here are two examples and none is working: both are launched this way: ---
- hosts: other
gather_facts: False
tasks:
- name: generate k8s yaml
copy:
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
dest: /tmp/files/deploy.yml
delegate_to: localhost
- name: add deploy
community.kubernetes.k8s:
state: present
src: /tmp/files/deploy.yml ---
- hosts: other
gather_facts: False
tasks:
- name: generate k8s yaml
copy:
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
dest: /tmp/files/deploy.yml
delegate_to: localhost
- name: add deploy
community.kubernetes.k8s:
state: present
src: deploy.yml (almost) same results both times: msg: and: $ ls -l /tmp/files/deploy.yml
-rw-r--r-- 1 sylvain staff 363 4 déc 13:41 /tmp/files/deploy.yml |
@Akasurde , thanks for the PR, it makes (half of) the bug disappears! |
---
- hosts: centos
tasks:
- name: generate k8s yaml
copy:
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-1
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
dest: /tmp/files/deploy.yml
delegate_to: localhost
- name: add deploy
community.kubernetes.k8s:
state: present
remote_src: True
src: /tmp/files/deploy.yml
|
@sylvainOL you are not specifying |
@Akasurde, well, as far as I understand the stuff, we have two options when using
Again, I believe here we have two issues:
And also, I find the default way counterintuitive as most tasks are executed by default on host and here it's the contrary |
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: ansible-collections#307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* k8s: Add a parameter remote_src remote_src is boolean parameter to specify if src file is located on remote node or Ansible Controller. Fixes: #307 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * remove parameters Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
SUMMARY
Use of
src
options fork8s
module seems to work only if Ansible Controller and Host are the sameISSUE TYPE
COMPONENT NAME
k8s
role version:
v1.1.1
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
had the issue on both MacOs and Debian
STEPS TO REPRODUCE
use two different machines:
other
in the playbook)first playbook I tried
second playbook tried (the same as before but generating the file on controller side):
EXPECTED RESULTS
I would have expected that one of the tries (preferrably first as it's the way it works with all modules) would have created the deployment.
ACTUAL RESULTS
FIRST TRY
we have an error (
ansible.errors.AnsibleFileNotFound: Could not find or access '/tmp/deploy.yml' on the Ansible Controller.
) saying the file should be on the Ansible controller.And we don't see actual command on
other
server:full playbook run:
SECOND TRY
As said by First run error, we put the file on the controller.
But we see here that the module tries to launch itself but the file is missing (as it's on the controller...)
The text was updated successfully, but these errors were encountered: