[Ansible - Semaphore playbook테스트] part 3

Mariadb 설치 yml파일 실행 테스트

[root@jh-semaphore playbooks]# vi dbinstall.yml
---
- name: mariadb_install
  hosts: all
  remote_user: root
  tasks:
   - name: Connection Test
     ping:
   - name: Install wget
     yum:
       name: wget
       state: present
   - name: Create directoty
     file:
       path: /root/Downloads
       state: directory
       mode: 0775
   - name: Download mariadb_repo_setup File
     get_url:
      url: https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
      dest: /root/Downloads
   - name: Change mode for mariadb_repo_setup
     file:
       dest: /root/Downloads/mariadb_repo_setup
       mode: 755
   - name: excute mariadb_repo_setup
     shell: /root/Downloads/mariadb_repo_setup
   - name: Delete mariadb_repo_setup
     file:
       state: absent
       path: /root/Downloads/mariadb_repo_setup
   - name: Install MariaDB-server
     yum:
       name: MariaDB-server
       state: present
   - name: Config 수정
     lineinfile:
       path: /etc/my.cnf
       regexp: '{{item.From}}'
       line: '{{item.To}}'
       state: present
     with_items:
       - { From: 'datadir=/var/lib/mysql', To: 'datadir=/data'}
       - { From: 'socket=/var/lib/mysql/mysql.sock', To: 'socket=/tmp/mysql.sock'}
       - { From: 'log-error=/var/log/mariadb/mariadb.log', To: 'log-error=/log/mariadb.log'}
       - { From: 'pid-file=/var/run/mariadb/mariadb.pid', To: 'pid-file=/log/mariadb.pid'}
   - name: Mariadb Start
     systemd:
       state: started
       daemon_reload: yes
       name: mariadb



[root@jh-semaphore playbooks]# git add dbinstall.yml

[root@jh-semaphore playbooks]# git commit -m "dbinstall.yml"
[master 31c3644] dbinstall.yml
1 file changed, 6 insertions(+), 1 deletion(-)

 

 

 Template

Inventory

 

 

run 실행

 

 

Target 서버에 Mariadb 설치 및 실행 상태 확인

[root@target ~]# ps -ef | grep mariadb
mysql    22031     1  0 17:39 ?        00:00:00 /usr/sbin/mariadbd
root     22136 21587  0 17:40 pts/0    00:00:00 grep --color=auto mariadb