Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- configure wn (
- @begin
- - tasks:
- - run_once: true
- shell: echo '{{OUTPORTS}}' | awk 'BEGIN {RS=","; FS="/"} { system("/sbin/iptables
- -I INPUT -p " $2 " --dport " $1 " -j ACCEPT"); }'
- when: ansible_os_family == "RedHat"
- vars:
- OUTPORTS: 15002/udp,15001/tcp,15004/tcp,15003/udp,15001/udp,8899/tcp,1023/udp,1023/tcp,15004/udp,15002/tcp,15003/tcp
- - tasks:
- - include_vars: '{{item}}'
- with_first_found:
- - '{{ ansible_os_family }}.yml'
- - RedHat.yml
- - name: Create User {{item.name}}
- user: name={{item.name}} password={{item.password}} shell=/bin/bash
- with_items: USERS
- - authorized_key: user={{item.name}} key="{{ lookup('file', '/tmp/' + item.name + '_id_rsa.pub') }}"
- name: Add the authorized_key to the user {{item.name}}
- with_items: USERS
- - include: sudo_copy.yml src=/home/{{item.name}}/.ssh/id_rsa.pub dest=/home/{{item.name}}/.ssh/id_rsa.pub
- owner={{item.name}} group={{item.name}} mode=0644 loop={{USERS}}
- name: Copy the id_rsa.pub file to the user
- - include: sudo_copy.yml src=/home/{{item.name}}/.ssh/id_rsa dest=/home/{{item.name}}/.ssh/id_rsa
- owner={{item.name}} group={{item.name}} mode=0600 loop={{USERS}}
- name: Copy the id_rsa file to the user
- - template: src=utils/templates/ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
- - apt: name=torque-mom,torque-client update_cache=yes cache_valid_time=3600
- name: Apt install torque mom
- when: ansible_os_family == "Debian"
- - name: create epel.repo
- template: src=utils/templates/epel-es.repo dest=/etc/yum.repos.d/epel.repo
- when: ansible_os_family == "RedHat"
- - name: Yum install Torque in REL system
- when: ansible_os_family == "RedHat"
- yum: name=torque-mom,torque-client,openssh-clients
- - include: munge_repo_wn.yml
- when: ansible_os_family == "RedHat"
- - copy: content=torqueserver dest=/etc/torque/server_name
- name: Set the Torque server name
- - copy:
- content: '$clienthost torqueserver
- $max_conn_timeout_micro_sec 10000
- $mom_host {{IM_NODE_HOSTNAME}}
- '
- dest: '{{TORQUE_PATH}}/mom_priv/config'
- group: root
- mode: 420
- owner: root
- name: Create the mom_priv/config file
- - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
- - command: sleep 5
- - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
- - service: name={{MOM_SERVICE}} state=started pattern=/usr/sbin/pbs_mom
- - command: sleep 5
- - service: name={{MOM_SERVICE}} state=started pattern=/usr/sbin/pbs_mom
- vars:
- USERS:
- - name: user1
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- @end
- )
- configure RedHat (
- @begin
- MOM_SERVICE: pbs_mom
- SCHED_SERVICE: pbs_sched
- TORQUE_PATH: /var/lib/torque
- TORQUE_SERVICE: pbs_server
- AUTH_SERVICE: trqauthd
- MAUI_SERVICE: maui
- @end
- )
- configure front (
- @begin
- - tasks:
- - run_once: true
- shell: echo '{{OUTPORTS}}' | awk 'BEGIN {RS=","; FS="/"} { system("/sbin/iptables
- -I INPUT -p " $2 " --dport " $1 " -j ACCEPT"); }'
- when: ansible_os_family == "RedHat"
- vars:
- OUTPORTS: 15002/udp,15001/tcp,15004/tcp,15003/udp,15001/udp,8899/tcp,1023/udp,1023/tcp,15004/udp,15002/tcp,15003/tcp
- - tasks:
- - include_vars: '{{item}}'
- with_first_found:
- - '{{ ansible_os_family }}.yml'
- - RedHat.yml
- - command: hostname torqueserver
- - name: create epel.repo
- template: src=utils/templates/epel-es.repo dest=/etc/yum.repos.d/epel.repo
- when: ansible_os_family == "RedHat"
- - user: name={{item.name}} password={{item.password}} generate_ssh_key=yes shell=/bin/bash
- with_items: USERS
- - local_action: command cp /home/{{item.name}}/.ssh/id_rsa.pub /tmp/{{item.name}}_id_rsa.pub
- creates=/tmp/{{item.name}}_id_rsa.pub
- with_items: USERS
- - authorized_key: user={{item.name}} key="{{ lookup('file', '/tmp/' + item.name + '_id_rsa.pub') }}"
- name: Add the authorized_key to the user {{item.name}}
- with_items: USERS
- - template: src=utils/templates/ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
- - shell: "for i in `seq 1 {{NNODES}}`; do\n item=\"vnode${i}\";\n grep -q \"\\\
- <${item}\\>\" /etc/hosts || echo \"127.0.0.1 ${item}.localdomain ${item}\" >>\
- \ /etc/hosts;\ndone\n"
- - apt: name=torque-server,torque-client,g++,libtorque2-dev,make update_cache=yes
- cache_valid_time=3600
- name: Apt install Torque in Deb system
- when: ansible_os_family == "Debian"
- - name: Yum install Torque in REL system
- when: ansible_os_family == "RedHat"
- yum: name=torque-server,torque-scheduler,torque-client,openssh-clients,gcc-c++,torque-devel,make
- - copy: dest=/etc/torque/server_name content=torqueserver
- - copy:
- content: '{% for number in range(1, NNODES|int + 1) %}
- vnode-{{number}}
- {% endfor %}
- '
- dest: '{{TORQUE_PATH}}/server_priv/nodes'
- - include: munge_repo_front.yml
- when: ansible_os_family == "RedHat"
- - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
- - command: sleep 5
- - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
- - service: name={{TORQUE_SERVICE}} state=restarted pattern=/usr/sbin/pbs_server
- - service: name={{TORQUE_SERVICE}} state=started pattern=/usr/sbin/pbs_server
- - shell: echo "{{PBS_SERVER_CONF}}" | qmgr creates={{TORQUE_PATH}}/server_priv/queues/batch
- - service: name={{SCHED_SERVICE}} state=started pattern=/usr/sbin/pbs_sched
- - command: sleep 5
- - service: name={{SCHED_SERVICE}} state=started pattern=/usr/sbin/pbs_sched
- - service: name={{TORQUE_SERVICE}} state=started pattern=/usr/sbin/pbs_server
- vars:
- USERS:
- - name: user1
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- NNODES: '@input.NumNodes@'
- PBS_SERVER_CONF: 'create queue batch
- set queue batch queue_type = Execution
- set queue batch resources_default.nodes = 1
- set queue batch enabled = True
- set queue batch started = True
- set server default_queue = batch
- set server scheduling = True
- set server scheduler_iteration = 20
- set server node_check_rate = 40
- set server resources_default.neednodes = 1
- set server resources_default.nodect = 1
- set server resources_default.nodes = 1
- set server query_other_jobs = True
- set server node_pack = False
- set server job_stat_rate = 30
- set server mom_job_sync = True
- set server authorized_users = *@torqueserver
- set server poll_jobs = True
- set tcp_timeout = 600
- '
- - tasks:
- - service: name={{SCHED_SERVICE}} state=stopped pattern=/usr/sbin/pbs_sched enabled=no
- - apt: name=libtorque2-dev,subversion
- when: ansible_os_family == "Debian"
- - when: ansible_os_family == "RedHat"
- yum: name=torque-devel,subversion
- - subversion: repo=svn://opensvn.adaptivecomputing.com/maui/branches/3.3.1 dest=/tmp/maui
- - command: ./configure --prefix=/usr/local/maui chdir=/tmp/maui/ creates=/tmp/maui/Makefile
- - command: make chdir=/tmp/maui creates=chdir=/tmp/maui/bin/maui
- - command: make install chdir=/tmp/maui creates=/usr/local/maui/maui.cfg
- - lineinfile: dest=/usr/local/maui/maui.cfg regexp=DEFERTIME line='DEFERTIME 0'
- - lineinfile: dest=/usr/local/maui/maui.cfg regexp=DEFERCOUNT line='DEFERCOUNT 99999'
- - ignore_errors: true
- name: kill maui if exists
- shell: kill -9 $(pgrep maui)
- - name: start maui daemon
- shell: cp /tmp/maui/etc/maui.d /etc/rc.d/init.d/maui
- - lineinfile: dest=/etc/rc.d/init.d/maui regexp='MAUI_PREFIX=/opt/maui' line='MAUI_PREFIX=/usr/local/maui'
- - service: name={{MAUI_SERVICE}} state=started pattern=/usr/local/maui/sbin/maui
- - copy:
- content: export PATH="$PATH:/usr/local/maui/bin"
- dest: /etc/profile.d/maui.sh
- name: add maui commands to the bash
- @end
- )
- configure munge_repo_wn (
- @begin
- - apt: name=munge update_cache=yes cache_valid_time=3600
- when: ansible_os_family == "Debian"
- - when: ansible_os_family == "RedHat"
- yum: name=munge
- - shell: echo -n "foo" | sha512sum | cut -d' ' -f1 >/etc/munge/munge.key
- - shell: chown munge.munge /etc/munge/munge.key
- - shell: chmod 400 /etc/munge/munge.key
- - file: path=/var/log/munge state=directory mode=0700
- - file: path=/var/log state=directory mode=0755
- - service: name=munge state=restarted
- @end
- )
- configure Debian (
- @begin
- MOM_SERVICE: torque-mom
- SCHED_SERVICE: torque-scheduler
- TORQUE_PATH: /var/spool/torque
- TORQUE_SERVICE: torque-server
- AUTH_SERVICE: trqauthd
- @end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement