1. Ansible을 사용한 서버 구축 자동화
ansible을 사용하여 클라우드 서버 A로 부터 B ,C의 인스턴스에 서버를 자동으로 구축 할 수 있도록
코드 작성
---
- name:
hosts: all
tasks:
- name: Install httpd php*
dnf:
name:
- httpd
- php
state: latest
- name: start httpd
service:
name: httpd
state: started
- name: enable php
service:
name: httpd
enabled: yes
- name: open firewall
firewalld:
service: "{{ item }}"
permanent: yes
state: enabled
immediate: yes
with_items:
- http
- ssh
- telnet
- ftp
- name: wget wordpress
shell: wget https://ko.wordpress.org/latest-ko_KR.zip
- name: unzip wordpress
shell: unzip latest-ko_KR.zip
- name: move wordpress
shell: mv wordpress /var/www/
- name: change owner
shell: chown -R apache:apache /var/www/html/
- name: change permission
shell: chmod -R 755 /var/www/html/
- name: link wordpress
shell: ln -s /var/www/html/wordpress
- name: restart httpd
service:
name: httpd
state: restarted
'네트워크 > Linux' 카테고리의 다른 글
[Linux] Docker (0) | 2025.03.20 |
---|---|
[Devops] Ansible 기초 (0) | 2025.03.06 |
[Linux] DHCP 설정 (0) | 2025.03.04 |
[Network] offset List (0) | 2025.02.25 |
[Linux] 메일 서버 구성 (0) | 2025.02.19 |