ansible assemble regexp to Assembles specific files

69 views
Skip to first unread message

samir patry

unread,
Jul 25, 2016, 4:08:28 PM7/25/16
to Ansible Project

I am using assemble module to make one file from multiple files. I have a list of files and from that list I want only .pub files to be assembled, but I am not sure how to use this.


list of files:

root_rsa_comiskey-v01
root_rsa_comiskey-v01.pub
root_rsa_comiskey-v02
root_rsa_comiskey-v02.pub
root_rsa_comiskey-v03
root_rsa_comiskey-v03.pub
root_rsa_comiskey-v05
root_rsa_comiskey-v05.pub

Playbook file:

---
- hosts: localhost
  become_user: yes
  tasks:
  - name: list files
    shell: ls -1 /tmp/root_ssh_key*
    register: dumpfiles

  - name: fetch files
    assemble: src=/tmp/root_ssh_key/ dest=/tmp/root_ssh_key/id_rsa regexp='(*.pub)'
    register: test

  - debug: var=test

Kai Stian Olstad

unread,
Jul 25, 2016, 4:41:50 PM7/25/16
to ansible...@googlegroups.com
You only need to change your regexp, this should work
regexp='.*\.pub$'

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages