Ansible yaml 剧本(傻瓜式)

2024-05-08 16:21:44 浏览数 (5)

优化ansible安装MySQL:

Ansible部署MySQL编译安装 - xiao智 - 博客园 (cnblogs.com)

Ansible yaml 剧本(傻瓜式):

代码语言:javascript复制
---
- hosts: webserv
  remote_user: root
  tasks: 
   - name: Install gcc gcc-c   ncurses-devel
     yum: yum remove mysql && yum install update
     yum: yum install -y gcc gcc-c   ncurses-devel wget
   - name: Copy cmake and mysql
     copy: src=/root/cmake-2.8.6.tar.gz /root/mysql-5.6.36.tar.gz dest=/root
     copy: src=/root/mysql-5.6.36.tar.gz dest=/root/
   - name: Tar 
     shell: tar -zxf /root/cmake-2.8.6.tar.gz -C /usr/src/
     sehll: tar -zxf /root/mysql-5.6.36.tar.gz -C /usr/src/
     shell: wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
   - name: Gmake install 
     shell: cd /usr/src/cmake-2.8.6 && ./configure && gmake && gmake install
   - name: Make install mysql
     shell: cd  /usr/src/mysql-5.6.36 && cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all && makec && make install 
   - name: Copy mysql my.cnf  and init.d
     shell: cp /usr/src/mysql-5.6.36/support-files/my-default.cnf /etc/my.cnf && cp /usr/src/mysql-5.6.36/support-files/mysql.server /etc/rc.d/init.d/mysqld && chmod a x /etc/rc.d/init.d/mysqld
    - name: Optimization path
     shell: ln -s /usr/local/mysql/bin/* /usr/local/bin

1 人点赞