playbook을 사용하여 apt update && apt upgrade
playbook 파일 내용 (filecopy.yml)
- 복제 대상 정보는 inventory 파일에 기록
$ cat inventory
[Server]
10.10.10.101
$ cat update-upgrade.yml
- name: apt update && apt uptrade
hosts: Server
become: yes
tasks:
- name: apt update
ansible.builtin.apt:
update_cache: yes
- name: apt upgrade
ansible.builtin.apt:
upgrade: dist
업그레이드 진행
$ ansible-playbook -i inventory update-upgrade.yml
$ ansible-playbook -i inventory update-upgrade.yml
SSH password:
BECOME password[defaults to SSH password]:
PLAY [apt update && apt uptrade] *********************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************
ok: [10.10.10.101]
TASK [apt update] ************************************************************************************************************************
changed: [10.10.10.101]
TASK [apt upgrade] ***********************************************************************************************************************
changed: [10.10.10.101]
PLAY RECAP *******************************************************************************************************************************
10.10.10.101 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
대상 서버 버전 정보 확인
작업 전
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
작업 후
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
리부팅은 적용되지 않아 리부팅은 추가적으로 진행 필요.