Ansible Module - ARCHIVING
remote_src: yes → src 파일이 원격지(remote)에 있는 파일일 때 설정
Create a playbook ~/playbooks/zip.yml to make a zip archive opt.zip of /opt directory on web1 node and save it under /root directory on web1 node itself.
- hosts: web1
tasks:
- archive:
path: /opt
dest: /root/opt.zip
format: zip
On Ansible controller (src: local), we have a zip archive local.zip. extract its contents on web1 under /tmp directory
- hosts: web1
tasks:
- unarchive:
src: local.zip
dest: /tmp
On web1 node(src: remote) we have an archive data.tar.gz under /root directory, extract it under /srv directory by developing a playbook.
data.tar.gz archive is removed after that
- hosts: web1
tasks:
- unarchive:
src: /root/data.tar.gz
dest: /src
remote_src: yes
- file:
path: /root/data.tar.gz
state: absent
download and extract the https://github.com/Hello-World/archive/master.zip zip archive under /root directory on the web1 node.
- hosts: web1
tasks:
- unarchive:
src: https://github.com/Hello-World/archive/master.zip
dest: /root
remote_src: yes
three files are on web1 node /root/file1.txt, /usr/local/share/file2.txt and /var/log/lastlog. Create a bz2 archive of all these files and save it under /root directory, name the archive as files.tar.bz2
- hosts: web1
tasks:
- archive:
path:
- /root/file1.txt
- /usr/local/share/file2.txt
- /var/log/lastlog
dest: /root/files.tar.bz2
format: bz2
a. Install nginx package and start/enable its service.
b. Extract /root/nginx.zip archive under /usr/share/nginx/html directory.
c. Inside /usr/share/nginx/html/index.html replace line This is sample html code with line This is Ansible lab.
- hosts: web1
tasks:
- yum:
name: nginx
state: present
- service:
name: nginx
state: started
enabled: yes
- unarchive:
src: /root/nginx.zip
dest: /usr/share/nginx/html
remote_src: yes
- replace:
path: /usr/share/nginx/html/index.html
regexp: 'This is sample html code'
replace: 'This is Ansible lab'
Author And Source
이 문제에 관하여(Ansible Module - ARCHIVING), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@codingdaddy/Ansible-Module-ARCHIVING저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)