marcoverl

ansible-torque-cluster

Feb 11th, 2016
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. configure wn (
  2. @begin
  3.  
  4. - tasks:
  5. - run_once: true
  6. shell: echo '{{OUTPORTS}}' | awk 'BEGIN {RS=","; FS="/"} { system("/sbin/iptables
  7. -I INPUT -p " $2 " --dport " $1 " -j ACCEPT"); }'
  8. when: ansible_os_family == "RedHat"
  9. vars:
  10. OUTPORTS: 15002/udp,15001/tcp,15004/tcp,15003/udp,15001/udp,8899/tcp,1023/udp,1023/tcp,15004/udp,15002/tcp,15003/tcp
  11. - tasks:
  12. - include_vars: '{{item}}'
  13. with_first_found:
  14. - '{{ ansible_os_family }}.yml'
  15. - RedHat.yml
  16. - name: Create User {{item.name}}
  17. user: name={{item.name}} password={{item.password}} shell=/bin/bash
  18. with_items: USERS
  19. - authorized_key: user={{item.name}} key="{{ lookup('file', '/tmp/' + item.name + '_id_rsa.pub') }}"
  20. name: Add the authorized_key to the user {{item.name}}
  21. with_items: USERS
  22. - include: sudo_copy.yml src=/home/{{item.name}}/.ssh/id_rsa.pub dest=/home/{{item.name}}/.ssh/id_rsa.pub
  23. owner={{item.name}} group={{item.name}} mode=0644 loop={{USERS}}
  24. name: Copy the id_rsa.pub file to the user
  25. - include: sudo_copy.yml src=/home/{{item.name}}/.ssh/id_rsa dest=/home/{{item.name}}/.ssh/id_rsa
  26. owner={{item.name}} group={{item.name}} mode=0600 loop={{USERS}}
  27. name: Copy the id_rsa file to the user
  28. - template: src=utils/templates/ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
  29. - apt: name=torque-mom,torque-client update_cache=yes cache_valid_time=3600
  30. name: Apt install torque mom
  31. when: ansible_os_family == "Debian"
  32. - name: create epel.repo
  33. template: src=utils/templates/epel-es.repo dest=/etc/yum.repos.d/epel.repo
  34. when: ansible_os_family == "RedHat"
  35. - name: Yum install Torque in REL system
  36. when: ansible_os_family == "RedHat"
  37. yum: name=torque-mom,torque-client,openssh-clients
  38. - include: munge_repo_wn.yml
  39. when: ansible_os_family == "RedHat"
  40. - copy: content=torqueserver dest=/etc/torque/server_name
  41. name: Set the Torque server name
  42. - copy:
  43. content: '$clienthost torqueserver
  44.  
  45. $max_conn_timeout_micro_sec 10000
  46.  
  47. $mom_host {{IM_NODE_HOSTNAME}}
  48.  
  49. '
  50. dest: '{{TORQUE_PATH}}/mom_priv/config'
  51. group: root
  52. mode: 420
  53. owner: root
  54. name: Create the mom_priv/config file
  55. - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
  56. - command: sleep 5
  57. - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
  58. - service: name={{MOM_SERVICE}} state=started pattern=/usr/sbin/pbs_mom
  59. - command: sleep 5
  60. - service: name={{MOM_SERVICE}} state=started pattern=/usr/sbin/pbs_mom
  61. vars:
  62. USERS:
  63. - name: user1
  64. password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
  65.  
  66.  
  67. @end
  68. )
  69. configure RedHat (
  70. @begin
  71.  
  72. MOM_SERVICE: pbs_mom
  73. SCHED_SERVICE: pbs_sched
  74. TORQUE_PATH: /var/lib/torque
  75. TORQUE_SERVICE: pbs_server
  76. AUTH_SERVICE: trqauthd
  77. MAUI_SERVICE: maui
  78.  
  79. @end
  80. )
  81. configure front (
  82. @begin
  83.  
  84. - tasks:
  85. - run_once: true
  86. shell: echo '{{OUTPORTS}}' | awk 'BEGIN {RS=","; FS="/"} { system("/sbin/iptables
  87. -I INPUT -p " $2 " --dport " $1 " -j ACCEPT"); }'
  88. when: ansible_os_family == "RedHat"
  89. vars:
  90. OUTPORTS: 15002/udp,15001/tcp,15004/tcp,15003/udp,15001/udp,8899/tcp,1023/udp,1023/tcp,15004/udp,15002/tcp,15003/tcp
  91. - tasks:
  92. - include_vars: '{{item}}'
  93. with_first_found:
  94. - '{{ ansible_os_family }}.yml'
  95. - RedHat.yml
  96. - command: hostname torqueserver
  97. - name: create epel.repo
  98. template: src=utils/templates/epel-es.repo dest=/etc/yum.repos.d/epel.repo
  99. when: ansible_os_family == "RedHat"
  100. - user: name={{item.name}} password={{item.password}} generate_ssh_key=yes shell=/bin/bash
  101. with_items: USERS
  102. - local_action: command cp /home/{{item.name}}/.ssh/id_rsa.pub /tmp/{{item.name}}_id_rsa.pub
  103. creates=/tmp/{{item.name}}_id_rsa.pub
  104. with_items: USERS
  105. - authorized_key: user={{item.name}} key="{{ lookup('file', '/tmp/' + item.name + '_id_rsa.pub') }}"
  106. name: Add the authorized_key to the user {{item.name}}
  107. with_items: USERS
  108. - template: src=utils/templates/ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
  109. - shell: "for i in `seq 1 {{NNODES}}`; do\n item=\"vnode${i}\";\n grep -q \"\\\
  110. <${item}\\>\" /etc/hosts || echo \"127.0.0.1 ${item}.localdomain ${item}\" >>\
  111. \ /etc/hosts;\ndone\n"
  112. - apt: name=torque-server,torque-client,g++,libtorque2-dev,make update_cache=yes
  113. cache_valid_time=3600
  114. name: Apt install Torque in Deb system
  115. when: ansible_os_family == "Debian"
  116. - name: Yum install Torque in REL system
  117. when: ansible_os_family == "RedHat"
  118. yum: name=torque-server,torque-scheduler,torque-client,openssh-clients,gcc-c++,torque-devel,make
  119. - copy: dest=/etc/torque/server_name content=torqueserver
  120. - copy:
  121. content: '{% for number in range(1, NNODES|int + 1) %}
  122.  
  123. vnode-{{number}}
  124.  
  125. {% endfor %}
  126.  
  127. '
  128. dest: '{{TORQUE_PATH}}/server_priv/nodes'
  129. - include: munge_repo_front.yml
  130. when: ansible_os_family == "RedHat"
  131. - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
  132. - command: sleep 5
  133. - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
  134. - service: name={{TORQUE_SERVICE}} state=restarted pattern=/usr/sbin/pbs_server
  135. - service: name={{TORQUE_SERVICE}} state=started pattern=/usr/sbin/pbs_server
  136. - shell: echo "{{PBS_SERVER_CONF}}" | qmgr creates={{TORQUE_PATH}}/server_priv/queues/batch
  137. - service: name={{SCHED_SERVICE}} state=started pattern=/usr/sbin/pbs_sched
  138. - command: sleep 5
  139. - service: name={{SCHED_SERVICE}} state=started pattern=/usr/sbin/pbs_sched
  140. - service: name={{TORQUE_SERVICE}} state=started pattern=/usr/sbin/pbs_server
  141. vars:
  142. USERS:
  143. - name: user1
  144. password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
  145. NNODES: '@input.NumNodes@'
  146. PBS_SERVER_CONF: 'create queue batch
  147.  
  148. set queue batch queue_type = Execution
  149.  
  150. set queue batch resources_default.nodes = 1
  151.  
  152. set queue batch enabled = True
  153.  
  154. set queue batch started = True
  155.  
  156. set server default_queue = batch
  157.  
  158. set server scheduling = True
  159.  
  160. set server scheduler_iteration = 20
  161.  
  162. set server node_check_rate = 40
  163.  
  164. set server resources_default.neednodes = 1
  165.  
  166. set server resources_default.nodect = 1
  167.  
  168. set server resources_default.nodes = 1
  169.  
  170. set server query_other_jobs = True
  171.  
  172. set server node_pack = False
  173.  
  174. set server job_stat_rate = 30
  175.  
  176. set server mom_job_sync = True
  177.  
  178. set server authorized_users = *@torqueserver
  179.  
  180. set server poll_jobs = True
  181.  
  182. set tcp_timeout = 600
  183.  
  184. '
  185. - tasks:
  186. - service: name={{SCHED_SERVICE}} state=stopped pattern=/usr/sbin/pbs_sched enabled=no
  187. - apt: name=libtorque2-dev,subversion
  188. when: ansible_os_family == "Debian"
  189. - when: ansible_os_family == "RedHat"
  190. yum: name=torque-devel,subversion
  191. - subversion: repo=svn://opensvn.adaptivecomputing.com/maui/branches/3.3.1 dest=/tmp/maui
  192. - command: ./configure --prefix=/usr/local/maui chdir=/tmp/maui/ creates=/tmp/maui/Makefile
  193. - command: make chdir=/tmp/maui creates=chdir=/tmp/maui/bin/maui
  194. - command: make install chdir=/tmp/maui creates=/usr/local/maui/maui.cfg
  195. - lineinfile: dest=/usr/local/maui/maui.cfg regexp=DEFERTIME line='DEFERTIME 0'
  196. - lineinfile: dest=/usr/local/maui/maui.cfg regexp=DEFERCOUNT line='DEFERCOUNT 99999'
  197. - ignore_errors: true
  198. name: kill maui if exists
  199. shell: kill -9 $(pgrep maui)
  200. - name: start maui daemon
  201. shell: cp /tmp/maui/etc/maui.d /etc/rc.d/init.d/maui
  202. - lineinfile: dest=/etc/rc.d/init.d/maui regexp='MAUI_PREFIX=/opt/maui' line='MAUI_PREFIX=/usr/local/maui'
  203. - service: name={{MAUI_SERVICE}} state=started pattern=/usr/local/maui/sbin/maui
  204. - copy:
  205. content: export PATH="$PATH:/usr/local/maui/bin"
  206. dest: /etc/profile.d/maui.sh
  207. name: add maui commands to the bash
  208.  
  209.  
  210. @end
  211. )
  212. configure munge_repo_wn (
  213. @begin
  214.  
  215. - apt: name=munge update_cache=yes cache_valid_time=3600
  216. when: ansible_os_family == "Debian"
  217. - when: ansible_os_family == "RedHat"
  218. yum: name=munge
  219. - shell: echo -n "foo" | sha512sum | cut -d' ' -f1 >/etc/munge/munge.key
  220. - shell: chown munge.munge /etc/munge/munge.key
  221. - shell: chmod 400 /etc/munge/munge.key
  222. - file: path=/var/log/munge state=directory mode=0700
  223. - file: path=/var/log state=directory mode=0755
  224. - service: name=munge state=restarted
  225.  
  226.  
  227. @end
  228. )
  229. configure Debian (
  230. @begin
  231.  
  232. MOM_SERVICE: torque-mom
  233. SCHED_SERVICE: torque-scheduler
  234. TORQUE_PATH: /var/spool/torque
  235. TORQUE_SERVICE: torque-server
  236. AUTH_SERVICE: trqauthd
  237.  
  238. @end
  239. )
RAW Paste Data