Ansible task to read definition file from the Ansible controller file system.

0 votes
I'm working on a small project for my college. I've to automate the entire process using Ansible. Most of it is done. This section says that I need to read a definition file from the Ansible controller file system. How do I write a playbook for it?
Jun 11 in Ansible by Laksha
26 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey, you can use the k8s module for this purpose. You can try something like this:

- name: Read file from the Ansible controller file system.
  
    k8s:
    state: present
    definition: "{{ lookup('file', '/path-to-file/deployment.yml') }}"

If You want your task to fail on errors, you can enable it by adding the following line

 validate:
      fail_on_error: yes
answered Jun 11 by Babita

Related Questions In Ansible

0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Ansible playbook to wget a file

Hey @Celia, one recommendation, try not using ...READ MORE

answered Jan 16 in Ansible by Vaishu
503 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.