test_nodes.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ---
  2. - hosts: all
  3. become: yes
  4. become_user: root
  5. become_method: sudo
  6. gather_facts: yes
  7. vars:
  8. consul_server_nodes:
  9. - 10.161.8.1
  10. - 10.161.16.94
  11. - 10.161.13.176
  12. pre_tasks:
  13. - name: Update Apt Cache
  14. apt: update_cache=yes cache_valid_time=86400
  15. when: ansible_os_family == "Debian"
  16. - name: Ubuntu Packages
  17. apt: >
  18. pkg={{item}}
  19. state=present
  20. with_items:
  21. - build-essential
  22. - autoconf
  23. - automake
  24. - libbsd-dev
  25. - libltdl-dev
  26. - libltdl7
  27. - libtool
  28. - libevent-openssl-2.1-6
  29. - libpcre3-dev
  30. - libevent-dev
  31. - pkg-config
  32. - zlib1g-dev
  33. - libssl-dev
  34. tasks:
  35. - name: create redis user
  36. user:
  37. name: redis
  38. uid: 4001
  39. shell: /bin/bash
  40. state: present
  41. - name: checkout redis git repo
  42. git:
  43. repo: 'https://github.com/antirez/redis'
  44. dest: /home/redis/redis
  45. version: 6.0
  46. - name: Build the default target
  47. make:
  48. chdir: /home/redis/redis
  49. - name: Run 'install' target as root
  50. make:
  51. chdir: /home/redis/redis
  52. target: install
  53. become: yes
  54. - name: checkout memtier_benchmark git repo
  55. git:
  56. repo: 'https://github.com/RedisLabs/memtier_benchmark'
  57. dest: /home/redis/memtier_benchmark
  58. version: 1.2.17
  59. - name: Run the autoconf
  60. command: autoreconf -ivf
  61. args:
  62. chdir: /home/redis/memtier_benchmark
  63. creates: /home/redis/memtier_benchmark/configure
  64. - name: Run the configure script first
  65. command: ./configure
  66. args:
  67. chdir: /home/redis/memtier_benchmark
  68. creates: /home/redis/memtier_benchmark/Makefile
  69. - name: Build the default target
  70. make:
  71. chdir: /home/redis/memtier_benchmark
  72. - name: Run 'memtier_benchmark install' target as root
  73. make:
  74. chdir: /home/redis/memtier_benchmark
  75. target: install
  76. become: yes
  77. - name: checkout twemproxy git repo
  78. git:
  79. repo: 'https://github.com/twitter/twemproxy'
  80. dest: /home/redis/twemproxy
  81. version: master
  82. - name: Run the autoconf in twemproxy
  83. command: autoreconf -ivf
  84. args:
  85. chdir: /home/redis/twemproxy
  86. creates: /home/redis/twemproxy/configure
  87. - name: Run the twemproxy configure
  88. command: ./configure
  89. args:
  90. chdir: /home/redis/twemproxy
  91. creates: /home/redis/twemproxy/Makefile
  92. - name: Build the twemporxy target
  93. make:
  94. chdir: /home/redis/twemproxy
  95. - name: Run 'twemproxy install' target as root
  96. make:
  97. chdir: /home/redis/twemproxy
  98. target: install
  99. become: yes
  100. roles:
  101. - ntp
  102. # - { role: consul-template,
  103. # consul_template_consul_server: 10.161.8.1,
  104. # consul_template_use_upstart: false }
  105. post_tasks:
  106. - name: create the redis dir
  107. file:
  108. path: /redis
  109. owner: redis
  110. group: redis
  111. mode: '0755'
  112. state: directory
  113. - name: Twemproxy-Template Systemd
  114. template:
  115. src: systemd_twemproxy-template.j2
  116. dest: /lib/systemd/system/twemproxy-template.service
  117. owner: root
  118. group: root
  119. mode: 0644
  120. - name: Twemproxy Systemd
  121. template:
  122. src: systemd_twemproxy.j2
  123. dest: /lib/systemd/system/twemproxy.service
  124. owner: root
  125. group: root
  126. mode: 0644
  127. - name: copy the nutcracker template file
  128. copy:
  129. src: twemproxy.ctmpl
  130. dest: /etc/nutcracker.ctmpl
  131. owner: redis
  132. group: redis
  133. mode: '0644'
  134. - name: create a temporary twemproxy config file
  135. shell: "echo \"cpredis:\n listen: 0.0.0.0:2112\n servers:\n - localhost:19901:1\" > /etc/nutcracker.yml"
  136. args:
  137. creates: /etc/nutcracker.yml
  138. - name: Enable Twemproxy Service
  139. systemd:
  140. name: twemproxy.service
  141. enabled: yes
  142. state: started
  143. - name: Enable Twemproxy-Template Service
  144. systemd:
  145. name: twemproxy-template.service
  146. enabled: yes
  147. state: started