码迷,mamicode.com
首页 > 数据库 > 详细

企业级ansible-role :通过role进行二进制批量部署mariadb从而批量上线sql系统

时间:2019-04-27 21:20:22      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:总结   state   RoCE   bin   tor   scripts   roo   temp   include   

总结构

技术图片

1

技术图片

- include: group.yml
- include: user.yml
- include: mkdir.yml
- include: data.yml
- include: link.yml
- include: linkstate.yml
- include: conf.yml
- include: server.yml

2

技术图片

- name: create group
  group: name=mysql system=yes gid=306

3

技术图片

- name: create user
  user: name=mysql system=yes uid=306 group=306 home=/data/mysql

4

技术图片

- name: mkdir
  file: name=/data/mysql owner=root group=mysql state=directory

5

技术图片

- name: copy data
  unarchive: src=mariadb-10.2.23-linux-x86_64.tar.gz  dest=/usr/local

6

技术图片

- name: link
  file: src=/usr/local/mariadb-10.2.23-linux-x86_64 dest=/usr/local/mysql state=link

7

技术图片

- name: link state
  file: name=/usr/local/mysql owner=root group=mysql

8

技术图片

- name: mkdir conf 
  file: path=/etc/mysql state=directory
- name: copy conf
  template: src=my-large.cnf.j2 dest=/etc/mysql/my.cnf

9

技术图片

- name: install
  shell: /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --user=mysql
- name: copy service conf
  template: src=mysql.server.j2 dest=/etc/rc.d/init.d/mysqld
- name: add service
  shell: chkconfig --add mysqld
- name: chmod
  shell: chmod +x /etc/init.d/mysqld
- name: start server
  shell: service mysqld start
- name: PATH
  shell: echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql
- name: source
  shell: source /etc/profile.d/mysql

10 安全初始化

#!/usr/bin/expect
set timeout 60
#set password [lindex $argv 0]
spawn mysql_secure_installation
expect {
        "enter for none" { send "\r"; exp_continue}
        "Change the root password" { send "\r"; exp_continue}
        "New password" { send "new passwd\r"; exp_continue}
        "Re-enter new password" { send "newpasswd\r"; exp_continue}
        "Remove anonymous users" { send "\r"; exp_continue}
        "Disallow root login remotely" { send "n\r"; exp_continue}
        "Remove test database and access to it" { send "\r"; exp_continue}
        "Reload privilege tables now" { send "\r"; exp_continue}
        "Cleaning up" { send "\r"}
}
interact ‘ > mysql_secure_installation.exp

企业级ansible-role :通过role进行二进制批量部署mariadb从而批量上线sql系统

标签:总结   state   RoCE   bin   tor   scripts   roo   temp   include   

原文地址:https://blog.51cto.com/9019400/2385735

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!