0

I would like to apply the ingress https://projectcontour.io/ to my kubernetes cluster with ansible community.kubernetes.k8s.

The example on https://docs.ansible.com/ansible/latest/collections/community/kubernetes/k8s_module.html shows me how to apply local files, for instance

- name: Create a Deployment by reading the definition from a local file
  community.kubernetes.k8s:
    state: present
    src: /testing/deployment.yml

However I could not find the example with remote file.

With kubectl the deployment of contour ingress can be done as follow:

kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

1

When I read the docs, I don't see an option to do that. You could download the file first, then apply it.

- name: retrieve file
  get_url:
    url: https://projectcontour.io/quickstart/contour.yaml
    dest: /testing/contour.yaml
  register: download_contour

- name: create deployment
  k8s:
    src: /testing/deployment.yml
  when: download_contour.changed
Kevin C
  • 4,851
  • 8
  • 30
  • 64
  • One more question, is it going to download on my local computer? Do I have to create a folder first? – softshipper Feb 08 '21 at 12:05
  • It will download on the target machine. If you want the command to be executed on the local machine, look at this example: https://stackoverflow.com/questions/18900236/run-command-on-the-ansible-host – Kevin C Feb 08 '21 at 13:25
  • The folder has to exist. I assume that was already done. You can use this example to create a folder beforehand: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html – Kevin C Feb 08 '21 at 13:26