Playbook 작성 실습 - Ansible로 MariaDB 설치 > Ansible 자료실

본문 바로가기
사이트 내 전체검색

Ansible 자료실

실습 Playbook 작성 실습 - Ansible로 MariaDB 설치

페이지 정보

profile_image
작성자 AnsibleM
댓글 0건 조회 8,717회 작성일 21-08-02 14:50

본문

1. SERVER SPEC

장비명 KVM - Virtual Machine
CPU Core 2
Memory 4096 MB
HDD 100 GB
OS Red Hat Enterprise Linux 8.3
Ansible 2.9.23
MariaDB 10.6.3

2. MariaDB 설치

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
- hosts: localhost
  gather_facts: False
  vars:
    mariadb_root_access_hosts:
      - 127.0.0.1
      - ::1
      - localhost
  vars_prompt:
  - name: mariadb_root_password
    prompt: What would you set the password for?
 
  tasks:
  - name: Install wget
    yum:
      name: wget
      state: present
 
  - 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: a+x
 
  - 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: restart service cron on centos, in all cases, also issue daemon-reload to pick up config changes
    systemd:
      state: started
      daemon_reload: yes
      name: mariadb
 
  - name: install pymysql
    pip:
      name: pymysql
      executable: pip3.6
 
  - name: Write root login credentials
    copy:
      dest: /root/.my.cnf
      owner: root
      group: root
      mode: 0600
      content: |
        [client]
        user=root
        password={{ mariadb_root_password }}
        socket=/var/lib/mysql/mysql.sock
 
  - name: test mysql_secure_installation
    mysql_user:
      user: root
      password: "{{mariadb_root_password}}"
      host: "{{item}}"
      login_unix_socket: /var/lib/mysql/mysql.sock
    with_items:
      - "{{mariadb_root_access_hosts}}"
 
  - name: Create a user with external access
    mysql_user:
      name: externalUser
      password: externalPassword
      host: "{{item}}"
      priv: "*.*:ALL"
      login_user: root
      login_password: "{{mariadb_root_password}}"
    with_items:
      - "{{mariadb_root_access_hosts}}"
      - "%"
 
  - name: deploy firewalld rules
    firewalld:
      immediate: yes
      service: mysql
      state: enabled
      permanent: yes
cs


3. Playbook 결과

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not
match 'all'
What would you set the password for?:

PLAY [localhost] ****************************************************************************************************

TASK [Install wget] *************************************************************************************************
ok: [localhost]

TASK [Download mariadb_repo_setup File] *****************************************************************************
changed: [localhost]

TASK [Change mode for mariadb_repo_setup] ***************************************************************************
changed: [localhost]

TASK [excute mariadb_repo_setup] ************************************************************************************
changed: [localhost]

TASK [Delete mariadb_repo_setup] ************************************************************************************
changed: [localhost]

TASK [Install MariaDB-server] ***************************************************************************************
changed: [localhost]

TASK [restart service cron on centos, in all cases, also issue daemon-reload to pick up config changes] *************
changed: [localhost]

TASK [install pymysql] **********************************************************************************************
changed: [localhost]

TASK [Write root login credentials] *********************************************************************************
changed: [localhost]

TASK [test mysql_secure_installation] *******************************************************************************
changed: [localhost] => (item=127.0.0.1)
changed: [localhost] => (item=::1)
changed: [localhost] => (item=localhost)
[WARNING]: Module did not set no_log for update_password

TASK [Create a user with external access] ***************************************************************************
changed: [localhost] => (item=127.0.0.1)
changed: [localhost] => (item=::1)
changed: [localhost] => (item=localhost)
changed: [localhost] => (item=%)

TASK [deploy firewalld rules] ***************************************************************************************
changed: [localhost]

PLAY RECAP *********************************************************************************************************

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

회사명 : (주)리눅스데이타시스템 / 대표 : 정정모
서울본사 : 서울특별시 강남구 봉은사로 114길 40 홍선빌딩 2층 / tel : 02-6207-1160
대전지사 : 대전광역시 유성구 노은로174 도원프라자 5층 / tel : 042-331-1161

접속자집계

오늘
1,188
어제
1,612
최대
3,935
전체
795,659
Copyright © www.linuxdata.org All rights reserved.