On 19. juli 2016 17:57, Alan Harkleroad wrote:
I am currently trying to copy a directories contents to a new directory so
we can do our SHA-384 and TLS upgrades to the system. When I have to copy
the variable list results to the new folder is where I am confusing my self
as to how that should look

My playbook likes like this.

---
- hosts: some-server-name
   become: true
   become_method: sudo
   tasks:

   - name: Create backup directory on remote server/servers
     file: path=/var/certs/certbkup
           state=present
           owner=root
           group=some-group
           mode=744

   - name: list directory specific contents
     shell: ls *.crt *.cer *.jks *.p12 /var/certs
     register: cert_results

   - name: copy list results to new folder
     command: cp {{item}} /var/certs/certbkup
     with_items: cert_results.stdout_lines

You have several option:

- name: list directory specific contents
  shell: ls *.crt *.cer *.jks *.p12
  args:
    chdir: /var/certs
  register: cert_results

- name: copy list results to new folder
  command: cp {{item}} /var/certs/certbkup
  args:
    chdir: /var/certs
  with_items: cert_results.stdout_lines

or just do in in one go

- name: backup files
  shell: cp *.crt *.cer *.jks *.p12 /var/certs/certbkup
  args:
    chdir: /var/certs


If you are copy all the files under /var/certs but not the directories I also think this would work (not tested).

- name: backup files
  synchronize:
    src=/var/certs/
    dest=/var/certs/certbkup/
    recursive=no

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/578E73E4.90402%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to