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, 2019 in Ansible by Laksha
1,245 views

1 answer to this question.

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, 2019 by Babita

Related Questions In Ansible

0 votes
1 answer

How to move/rename a file using an Ansible task on a remote system?

Hi@akhtar, You can use the command module to ...READ MORE

answered Sep 17, 2020 in Ansible by MD
• 95,460 points
20,347 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,944 views
+2 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, 2019 in Ansible by Vaishu
17,516 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP