앤서블이 제어하는 인벤토리 호스트에서의 파일을 끌어오기 위한 플러그인
취약점 결과를 파일로 남겨 앤서블 서버에 결과파일을 업로딩하는 플레이북
---
- hosts: all
become: yes
vars:
ansible_become_password: "{{ sudopasswd }}"
tasks:
# 인벤토리 호스트의 /root/에 check.sh 스크립트 배포
- name: deploy check script
copy:
src: /data/ansible/file/check.sh
dest: /root/check.sh
# 실행을 위한 권한 수정
- name: exec chmod check script
shell:
cmd: chmod 755 /root/check.sh
# check.sh 스크립트 실행&결과 저장
- name: exec check script
shell:
cmd: /root/check.sh
register: result
# check.sh 스크립트 수행결과 출력
- name: result
debug:
msg: "{{ result.stdout_lines }}"
# 결과 파일 앤서블서버 /data/checkfile/에 업로드
- name: fetch result file
fetch:
src: "/root/[RESULT]_{{ ansible_hostname }}_OE.tar.gz"
dest: "/data/checkfile/"
flat: yes
어떤 호스트에서 왔는지 구별하기위해 파일명에 호스트네임을 넣었는데 이 경우
Gather facts에서 수집되는 변수 {{ ansible_hostname }}를 이용했다.
앤서블 파일 배포
ansible file deploy
ansible file fetch
ansible 파일 끌어오기
ansible file pull
반응형
'인프라 > 앤서블(Ansible)' 카테고리의 다른 글
[Ansible] ansible windows dns 설정 (0) | 2022.08.08 |
---|---|
[Ansible] 앤서블 와일드카드 find 아스테리크 (0) | 2022.07.30 |
[Ansible] windows 파일배포 & 압축 해제 (0) | 2022.07.27 |
[Ansible] ansible apt update playbook (0) | 2022.07.20 |
[Ansible] windows powershell 파일 실행하기 (0) | 2022.07.19 |
댓글