Ansible-playplaybooks batch installation of Redis scripts

Source: Internet
Author: User
Tags vars

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


How to use:

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 '} "


Parameter description:

    • IP: Destination Host

    • Url:redis Package

    • Redis_home:redis installation directory

    • Redis_port:redis Listening Port


More examples refer to my github:https://github.com/miaocbin/ansible-playbooks

Welcome Message Exchange!

This article is from the "Cold Tea" blog, please be sure to keep this source http://miaocbin.blog.51cto.com/689091/1885046

Ansible-playplaybooks batch installation of Redis scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.