首页 > 代码库 > ansible-playplaybooks批量安装redis脚本
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=http://www.mamicode.com/tmp/libunwind-1.1.tar.gz dest=/tmp/ copy=no"/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=http://www.mamicode.com/tmp/redis.tar.gz dest=/tmp/redis/ copy=no>
使用方法:
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
欢迎留言交流!
本文出自 “冷水泡茶” 博客,请务必保留此出处http://miaocbin.blog.51cto.com/689091/1885046
ansible-playplaybooks批量安装redis脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。