Created
March 8, 2021 07:28
-
-
Save heiwa4126/d6cb9576cff8e0426702d15d20c2163c to your computer and use it in GitHub Desktop.
Ansibleのfindモジュールの例。/etc/*.confをコントロールマシンにコピーする。Jinja2のフィルタがめんどくさいがshell:つかうよりはいいんじゃないかと。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: fetch /etc/*.conf | |
| hosts: linux | |
| become: false | |
| gather_facts: false | |
| vars: | |
| outpath: "{{ playbook_dir }}/var/etc_conf/{{ inventory_hostname }}" | |
| tasks: | |
| - name: get list | |
| find: | |
| path: /etc | |
| pattern: "*.conf" | |
| register: rc | |
| # - debug: var=rc | |
| # - debug: msg="{{ rc.files|map(attribute='path') }}" | |
| - name: fetch /etc/*.conf files | |
| fetch: | |
| src: "{{ item }}" | |
| dest: "{{ outpath }}/" | |
| flat: true | |
| with_items: "{{ rc.files|map(attribute='path') }}" | |
| become: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment