2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AnsibleでRedisの2.5以降のバージョンをインストールするPlaybook

Last updated at Posted at 2015-06-11

AnsibleでRedisのインストールを自動化しようとしたのですが、
yumからRedisをインストールする場合、バージョンが2.4までしか取得できません。

しかしバージョン2.8を使いたかったため、面倒ですがソースからRedisをインストールすることにしました。
なおOSはCentOS6.5です。

playbook.yml
---
- hosts: hostuo
  sudo: yes
  tasks:
    - name: libselinux-python install
      yum: name=libselinux-python state=latest
    - name: gcc install
      yum: name=gcc state=latest
    - name: redis source download
      get_url: >
        url=http://download.redis.io/releases/redis-2.8.19.tar.gz
        dest=/tmp/redis-2.8.19.tar.gz
    - name: redis unarchive
      command: >
        tar zxvf redis-2.8.19.tar.gz
        chdir=/tmp/
    - name: make
      command: >
        make
        chdir=/tmp/redis-2.8.19
    - name: make install
      command: >
        make install
        chdir=/tmp/redis-2.8.19
    - name: deamonize on
      replace: >
        dest=/tmp/redis-2.8.19/redis.conf
        regexp='daemonize no'
        replace='daemonize yes'
    - name: redis.conf copy
      copy: >
        src=/tmp/redis-2.8.19/redis.conf
        dest=/etc/redis.conf
        owner=vagrant
    - name: redis start
      command: >
        redis-server /etc/redis.conf
      sudo: no

ansible-playbookを実行します。

$ ansible-playbook playbook.yml

PLAY [127.0.0.1] ************************************************************** 
~中略~
PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/username/playbook.retry

127.0.0.1                  : ok=10    changed=10    unreachable=0    failed=0 

上手くいけたようでした。

$ redis-server -v
Redis server v=2.8.19 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=6456d4b7b0a33b29

$ redis-cli
127.0.0.1:6379> 
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?