Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible: read remote file

I generate files with ansible on remote host and after this generation, I would like to read theses files in another task.

I don't find any module to read remote file with ansible (lookup seems only on local host).

Do you know a module like this ?

Thanks

EDIT:

Here is my use case:

I generate ssh keys and I add it to github. These keys are setting by an object in var files so I loop like this to generate it:

    tasks:   - name: Create ssh key     user:       name: "{{sshConfigFile.user}}"       generate_ssh_key: yes       ssh_key_file: ".ssh/{{item.value.file}}"       state: present     with_dict: "{{sshConfiguration}}" 

It works very fine but how read these keys to send it to github via the API ?

like image 974
Kiva Avatar asked Jan 11 '16 13:01

Kiva


1 Answers

Either run with the --diff flag (outputs a diff when the destination file changes) ..

ansible-playbook --diff server.yaml 

or slurp it up ..

- name: Slurp hosts file   slurp:     src: /etc/hosts   register: slurpfile  - debug: msg="{{ slurpfile['content'] | b64decode }}" 
like image 100
danday74 Avatar answered Oct 14 '22 11:10

danday74