목록Project (18)
ITFragile

앞서 작성한 haproxy.cfg.j2에는 lb서버가 web을 로드밸런싱 할 수 있도록 frontend, backend 정보가 작성되어 있었다. DB도 lb 서버를 통해 백엔드로 전달될 수 있도록 설정한다. 1. haproxy.cfg.j2 수정 # haproxy.cfg.j2 frontend web-lb bind *:80 default_backend webserver option forwardfor backend webserver balance roundrobin {% for host in groups['web'] %} server {{ hostvars[host].inventory_hostname }} {{ hostvars[host]['ansible_facts']['enp0s8']['ipv4']['addr..

1. DB와 WEB을 연결해주기 위해 main 플레이북 하단에 새 파일 연결 # main.yaml - name: DB WEB Connection hosts: web tasks: - import_tasks: php.yaml 2. php 설치 및 index.php 전달 # php.yaml - name: yum install python apt: name: - python3-pymysql - php - php-mysql state: latest - name: copy index.php template: # 템플릿 파일을 지정된 이름으로 원격 서버에 복사 src: index.php dest: /var/www/html - name: restart apache2 service: name: apache2 state:..

♡ 사용모듈 mysql_user : 사용자 생성 작업 mysql_db : DB 생성 작업 mysql_query : SQL 작업 MySQL collection 설치 Ansible Galaxy ansible-galaxy collection install community.mysql ★ create user # db.yaml - name: Create User mysql mysql_user: # user 생성 모듈 name: web_user password: 12345 host: '%' priv: '*.*:ALL' state: present [db-m01 접속 확인] [db-s01 접속 확인] ★ create DB # db-m01 - name: Create User mysql mysql_user: name: ..

♡ 사용모듈 mysql_secure_installation : root 비밀번호 초기화 및 보안 강화를 위한 설정 mysql_replication : 이중화 작업 1. mysql_secure_installation 모듈 설치 https://github.com/eslam-gomaa/mysql_secure_installation_Ansible 참조하여 py 설치 mkdir ~/.ansible/plugins/modules wget https://raw.githubusercontent.com/eslam-gomaa/mysql_secure_installation_Ansible/master/library/mysql_secure_installation.py 2. mysql_secure_installation Setti..

컨트롤노드에서 작성한 index.html을 web01,02에 로드밸런싱되게 옮기려고 함 1. main 플레이북 추가 2. index.html 작성 #controlnode # vim index.html Welcome to Kyungeun's Page!!! 3. 플레이북 작성 # index.yaml - name: copy index.html template: src: index.html dest: /var/www/html - name: rewrite index.html lineinfile: # 해당 경로의 파일 내용 변경 path: /var/www/html/index.html regexp: "^Welcome" line: Welcome to Kyungeun's Page!!! {{ ansible_facts.ho..

메인 플레이북에 import_tasks 모듈로 haproxy.yaml 파일을 불러오게 작성하고, 이 haproxy를 통해 webserver 01,02를 로드밸런싱 할 수 있도록 설정한다. 1. main 플레이북 작성 [main.yaml] 2. haproxy 플레이북 작성 # haproxy.yaml - name: haproxy template setting template: # 템플릿 파일을 지정된 이름으로 원격 서버에 복사 src: haproxy.cfg.j2 # 해당 파일 필요 dest: /etc/haproxy/haproxy.cfg - name: restart haproxy service: name: haproxy state: restarted 3. haproxy.cfg.j2 작성 # vim haprox..