shared.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ---
  2. - name: Create redis group
  3. group:
  4. name: redis
  5. state: present
  6. gid: 8000
  7. - name: Create redis user
  8. user:
  9. name: redis
  10. group: redis
  11. uid: 8000
  12. shell: /usr/sbin/nologin
  13. state: present
  14. - name: Soft file ulimit for redis user
  15. lineinfile:
  16. path: /etc/security/limits.conf
  17. regexp: '^redis\s+soft\s+nofile\s+65000'
  18. line: "redis soft nofile 65000"
  19. - name: Hard file ulimit for redis user
  20. lineinfile:
  21. path: /etc/security/limits.conf
  22. regexp: '^redis\s+hard\s+nofile\s+65000'
  23. line: "redis hard nofile 65000"
  24. # TODO: change this to check the value first
  25. - name: Setup RPS
  26. shell: "echo '1' > /sys/class/net/{{ ansible_default_ipv4.interface }}/queues/rx-0/rps_cpus"
  27. # TODO: change this to check the value first
  28. - name: Disable transparent hugepages
  29. shell: "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled"
  30. - name: Ensure redis-tools are installed
  31. package:
  32. name: redis-tools
  33. state: present
  34. - name: Sysctl Settings
  35. sysctl:
  36. name: "{{item.name}}"
  37. value: "{{item.value}}"
  38. reload: yes
  39. with_items:
  40. - { name: "vm.swappiness", value: "0"}
  41. - { name: "net.ipv4.tcp_sack", value: "1"}
  42. - { name: "net.ipv4.tcp_timestamps", value: "1"}
  43. - { name: "net.ipv4.tcp_window_scaling", value: "1"}
  44. - { name: "net.ipv4.tcp_congestion_control", value: "cubic"}
  45. - { name: "net.ipv4.tcp_syncookies", value: "1"}
  46. - { name: "net.ipv4.tcp_tw_recycle", value: "1"}
  47. - { name: "net.ipv4.tcp_max_syn_backlog", value: "1024"}
  48. - { name: "net.core.somaxconn", value: "1024"}
  49. - { name: "net.core.rmem_max", value: "425984"}
  50. - { name: "net.core.wmem_max", value: "425984"}
  51. - name: Set hostname
  52. hostname:
  53. name: "{{ inventory_hostname }}"
  54. - name: Set /etc/hosts
  55. lineinfile:
  56. path: /etc/hosts
  57. regexp: "{{inventory_hostname}}"
  58. line: "127.0.0.1 {{inventory_hostname}}"
  59. owner: root
  60. group: root
  61. mode: 0644