0
votes

Is it possible to execute a local script on a remote host in Ansible without copying it across and then executing it?

The script, shell and command modules all seems like they might be the answer but I'm not sure which is best.

The script module describes itself as "Runs a local script on a remote node after transferring it" but the examples given don't suggest a copy operation - e.g. no src, dest - so maybe this is the answer?

1
downvoters plz leave feedback thx - danday74
It might be the txtspk that encourages downvotes, since it creates work for volunteer editors. Please try to use real words here - this is not Facebook. - halfer

1 Answers

0
votes

script module FTW

tasks:

- name: Ensure docker repo is added
  script: "{{ role_path }}/files/add-docker-repo.sh"
  register: dockeraddrepo
  notify: Done dockeraddrepo
  when: ansible_local.dockeraddrepo | d(0) == 0

handlers:

- name: Done dockeraddrepo
  copy:
    content: '{{ dockeraddrepo }}'
    dest: /etc/ansible/facts.d/dockeraddrepo.fact