ansible安装redis playbook剧本

- hosts: all

  user: root

  tasks:

    - name: 上传安装包

      copy: src=/usr/local/src/redis-6.2.7.tar.gz dest=/usr/local/src/

    - name: 解压编译安装包

      shell: |

        cd /usr/local/src

        tar -zxvf redis-6.2.7.tar.gz

        cd redis-6.2.7

        make

        make PREFIX=/usr/local/redis install

    - name: 复制配置文件到conf下

      copy: src=/usr/local/src/redis-6.2.7/redis.conf dest=/usr/local/redis/bin

    - name: 修改配置文件

      lineinfile:

        dest: /usr/local/redis/bin/redis.conf

        regex: '^daemonize no'

        line: 'daemonize yes'

    - name: 修改配置文件

      lineinfile:

        dest: /usr/local/redis/bin/redis.conf

        regex: '^bind 127.0.0.1 -::1'

        line: 'bind 0.0.0.0'

#    - name: 进入指定目录启动命令

#      shell: |

#        cd /usr/local/redis/bin

#        ./redis-cli -p 6379 shutdown

    - name: 进入指定目录启动命令

      shell: |

        cd /usr/local/redis/bin

        ./redis-server /usr/local/redis/bin/redis.conf

猜你喜欢

转载自blog.csdn.net/love_THL/article/details/127405573
今日推荐