ansible-playplaybooks批量安装redis脚本
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,cat redis-install.yml ---- name: install redis gather_facts: False hosts: "{{ ip }}" user: root
千家信息网最后更新 2025年12月02日ansible-playplaybooks批量安装redis脚本
cat redis-install.yml ---- name: install redis gather_facts: False hosts: "{{ ip }}" user: root vars: - redis_port: "{{ port|default(6379) }}" tasks:# - name: remove the old file# file: path={{ redis_home }} state=absent - name: remove the tmp file file: path=/tmp/redis* state=absent - name: Create the dir file: path={{ item }} state=directory with_items: - /etc/redis/ - /tmp/redis/ - "{{ redis_home }}" - "{{ redis_home }}/data" - "{{ redis_home }}/data/{{ redis_port }}" - name: prepare the environment yum: name={{ item }} state=present with_items: - gcc - gcc-* - automake - autoconf - libtool - make - zlib - zlib-devel - glibc-* - tcl ignore_errors: yes - name: get libunwind-1.1_tar.gz get_url: url=http://nongnu.askapache.com/libunwind/libunwind-1.1.tar.gz dest=/tmp/libunwind-1.1.tar.gz - name: unarchive the libunwind-1.1_tar.gz unarchive: src=/tmp/libunwind-1.1.tar.gz dest=/tmp/ copy=no - name: install the libunwind-1.1_tar.gz shell: cd /tmp/libunwind-1.1/ && ./configure && make && make install - name: get gperftools-2.5_tar.gz get_url: url=https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz dest=/tmp/gperftools-2.5.tar.gz - name: unarchive the gperftools-2.5_tar.gz unarchive: src=/tmp/gperftools-2.5.tar.gz dest=/tmp/ copy=no - name: install the gperftools-2.5_tar.gz shell: cd /tmp/gperftools-2.5/ && ./configure && make && make install - name: ldconfig the /usr/local/lib shell: echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf && ldconfig - name: get redis_tar_gz get_url: url={{ url }} dest=/tmp/redis.tar.gz - name: unarchive the redis.tar.gz unarchive: src=/tmp/redis.tar.gz dest=/tmp/redis/ copy=no - name: install redis to {{ redis_home }} shell: cd /tmp/redis/ && make PREFIX={{ redis_home }} USE_TCMALLOC=yes install - name: init the redis_conf template: src=/ansible/roles/redis/templates/redis.conf.j2 dest=/etc/redis/redis-{{ redis_port }}.conf - name: init the redis maintain script template: src=/ansible/roles/redis/templates/redis.sh.j2 dest=/etc/init.d/redis-{{ redis_port }} mode=0755 - name: Start the redis server shell: /etc/init.d/redis-{{ redis_port }} start ignore_errors: yes - name: add redis to chkconfig shell: chkconfig --level 345 redis-{{ redis_port }} on ignore_errors: yes使用方法:
ansible-playbook redis-install.yml --extra-vars "{'ip':'redis-server','url':'http://download.redis.io/releases/redis-3.2.0.tar.gz','redis_home':'/usr/local/redis','redis_port':'6380'}"参数说明:
ip:目标主机
url:redis软件包下载地址
redis_home:redis安装目录
redis_port:redis监听端口
更多示例参考我的github:https://github.com/miaocbin/ansible-playbooks
欢迎留言交流!
主机
使用方法
参数
地址
方法
更多
目录
目标
示例
端口
软件
软件包
交流
参考
监听
脚本
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
常州小型工控机服务器
黑白手抄报网络安全
罗湖区服务器机柜价格
一体化办公网络安全保密
数据库服务开启就停止工作
软件开发合同填写说明
关于网络安全的有趣图片
控车软件开发
北京江鸟网络技术
关于网络安全的阅读
怎么投资手机软件开发
无服务器的好处和坏处
最佳阵容服务器
资讯行数据库网
宁波数据网络技术包括什么
软件开发适合什么公务员
大学生网络安全宣传周标语
数据库性能的主要指标
注销微信多久腾讯服务器才清空
盐城节能刀片服务器定制
软件开发行业投资估算
安卓远程启动服务器下载
远程服务器怎么连接失败
首届军营网络安全宣传片
云服务器 按量计费
立项申请书与软件开发
公司系统服务器辐射大吗
茂名通信软件开发价钱
廊坊软件开发参考价
机架式服务器gpu