Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No yaml syntax for ansible local_action?

Tags:

ansible

I have a working local_action task which I like to write in yaml syntax. But it seems that this is either not possible or tricky. There are some mentions in the net that people have tried to do so. I have not found a proof that it is not possible...

This is the working code (inline):

- name: create opt file
  local_action:  template  src=templates/module-deployment.opt.j2  dest=/tmp/{{ inventory_hostname }}/module-deployment.opt 

This is my closest version to structure the code (but not yaml syntax):

- name: create opt file
  local_action:  template
    src=templates/module-deployment.opt.j2   
    dest=/tmp/{{ inventory_hostname }}/module-deployment.opt

This is what I would have expected but this is not working:

  - name: create opt file
    local_action:  
    template: 
       src: templates/module-deployment.opt.j2   
       dest: tmp/{{ inventory_hostname }}/module-deployment.opt

The error message is not too helpful.

The offending line appears to be:
- name: create opt file for contentPump
  ^ here

Does anyone know if it is possible to archive this?

like image 736
Michael Hoeller Avatar asked Mar 08 '23 08:03

Michael Hoeller


1 Answers

This is what I would have expected but this is not working [ ]

You can always rely on the documentation instead of your own expectations:

- name: create opt file 
  local_action:
    module: template
    src: templates/module-deployment.opt.j2
    dest: tmp/{{ inventory_hostname }}/module-deployment.opt
like image 86
techraf Avatar answered May 18 '23 18:05

techraf