Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- network private ( provider_id = 'GRID-CERTIFICATION-wan' )
- network public ( outports = '15002/udp,15001/tcp,15004/tcp,15003/udp,15001/udp,1023/tcp,1023/udp,8899/tcp,15004/udp,15002/tcp,15003/
- tcp' and outbound = 'yes' and provider_id = 'GRID-CERTIFICATION-wan' and pool_name = 'Ext' )
- contextualize (
- system front configure front step 1
- system wn configure wn step 2
- )
- deploy front 1 ost
- deploy wn @input.NumNodes@ ost
- system wn (
- disk.0.os.credentials.username = 'centos' and
- instance_type = 'cldareapd.medium' and
- net_interface.0.connection = 'private' and
- disk.0.os.name = 'linux' and
- #Image for CentOS 7
- disk.0.image.url = 'ost://cloud-areapd.pd.infn.it/7544a870-90a6-4409-9a7d-5b376c278688'
- )
- system front (
- disk.0.os.credentials.username = 'centos' and
- queue_system = 'torque' and
- instance_type = 'cldareapd.small' and
- net_interface.0.connection = 'public' and
- net_interface.1.connection = 'private' and
- net_interface.1.dns_name = 'torqueserver.localdomain' and
- disk.0.os.name = 'linux' and
- #Image for CentOS 7
- disk.0.image.url = 'ost://cloud-areapd.pd.infn.it/7544a870-90a6-4409-9a7d-5b376c278688'
- )
- configure wn (
- @begin
- - tasks:
- - ignore_errors: true
- command: service firewalld stop
- - 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.localdomain dest=/etc/torque/server_name
- name: Set the Torque server name
- - copy:
- content: '$pbsserver torqueserver.localdomain
- $logevent 255
- '
- dest: '{{TORQUE_PATH}}/mom_priv/torque.cfg'
- group: root
- mode: 0644
- owner: root
- name: Create the mom_priv/torque.cfg file
- - copy:
- content: '$clienthost torqueserver.localdomain
- $max_conn_timeout_micro_sec 10000
- $mom_host {{IM_NODE_HOSTNAME}}
- '
- dest: '{{TORQUE_PATH}}/mom_priv/config'
- group: root
- mode: 0644
- owner: root
- name: Create the mom_priv/config file
- - copy:
- content: 'nodes=0
- '
- dest: '{{TORQUE_PATH}}/mom_priv/mom.layout'
- group: root
- mode: 0644
- owner: root
- name: Create the mom_priv/mom.layout file
- - command: /usr/sbin/trqauthd creates=/tmp/trqauthd-unix
- - shell: sleep 5
- - service: name={{MOM_SERVICE}} state=started pattern=/usr/sbin/pbs_mom
- - shell: sleep 5
- - shell: kill -9 $(pgrep trqauthd)
- - service: name={{AUTH_SERVICE}} state=started pattern=/usr/sbin/trqauthd
- - service: name={{MOM_SERVICE}} state=restarted pattern=/usr/sbin/pbs_mom
- vars:
- USERS:
- - name: user1
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- - name: dteam001
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- @end
- )
- configure front (
- @begin
- - tasks:
- - ignore_errors: true
- command: service firewalld stop
- - include_vars: '{{item}}'
- with_first_found:
- - '{{ ansible_os_family }}.yml'
- - RedHat.yml
- - command: hostname torqueserver.localdomain
- - 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
- - 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 state=present
- - include: munge_repo_front.yml
- when: ansible_os_family == "RedHat"
- - copy: dest=/etc/torque/server_name content=torqueserver.localdomain group=root mode=0644 owner=root
- - copy:
- content: '{% for number in range(0, NNODES|int + 1) %}
- vnode-{{number}} np=2 num_node_boards=1
- {% endfor %}
- '
- dest: /etc/torque/nodes
- group: root
- mode: 0644
- owner: root
- name: create /etc/torque/nodes file
- - file: src=/etc/torque/nodes dest='{{TORQUE_PATH}}/server_priv/nodes' owner=root group=root state=link
- name: create symlink
- - command: /usr/sbin/trqauthd creates=/tmp/trqauthd-unix
- name: starting trqauthd
- - shell: sleep 5
- - command: pbs_server -t create -f creates='{{TORQUE_PATH}}/server_priv/server.lock'
- name: first start of pbs_server
- - shell: sleep 5
- - shell: echo "set server operators += root@torqueserver.localdomain" | qmgr
- - shell: echo "set server managers += root@torqueserver.localdomain" | qmgr
- - command: qmgr -c 'create queue batch'
- - command: qmgr -c 'set queue batch queue_type = Execution'
- - command: qmgr -c 'set queue batch resources_default.nodes = 1'
- - command: qmgr -c 'set queue batch enabled = True'
- - command: qmgr -c 'set queue batch started = True'
- - command: qmgr -c 'set server default_queue = batch'
- - command: qmgr -c 'set server scheduling = True'
- - command: qmgr -c 'set server scheduler_iteration = 20'
- - command: qmgr -c 'set server node_check_rate = 40'
- - command: qmgr -c 'set server resources_default.neednodes = 1'
- - command: qmgr -c 'set server resources_default.nodect = 1'
- - command: qmgr -c 'set server resources_default.nodes = 1'
- - command: qmgr -c 'set server query_other_jobs = True'
- - command: qmgr -c 'set server node_pack = False'
- - command: qmgr -c 'set server job_stat_rate = 30'
- - command: qmgr -c 'set server mom_job_sync = True'
- - command: qmgr -c 'set server authorized_users = *@torqueserver.localdomain'
- - command: qmgr -c 'set server poll_jobs = True'
- name: qmgr configuration executed
- - shell: pgrep pbs_server && qterm && sleep 5
- name: pbs_server killed
- - service: name={{TORQUE_SERVICE}} state=started pattern=/usr/sbin/pbs_server enabled=yes
- vars:
- USERS:
- - name: user1
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- - name: dteam001
- password: $6$Ehg4GHQT5y$6ZCTLffp.epiNEhS1M3ZB.P6Kii1wELySe/DCwUInGt8r7zgdAHfHw66DuPwpS6pfOiZ9PS/KaTiBKjoCn23t0
- NNODES: '@input.NumNodes@'
- - tasks:
- - 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'
- - lineinfile: dest=/usr/local/maui/maui.cfg regexp='LOGFILE ' line='LOGFILE /var/log/torque/sched_logs/maui.log'
- - copy:
- content: export PATH="$PATH:/usr/local/maui/bin"
- dest: /etc/profile.d/maui.sh
- name: add maui commands to the bash
- - copy:
- content: '[Unit]
- Description=maui-sched
- After=syslog.target network.target trqauthd.service
- [Service]
- EnvironmentFile=/usr/local/maui/maui.cfg
- Type=forking
- ExecStart=/usr/local/maui/sbin/maui --configfile=/usr/local/maui/maui.cfg
- [Install]
- WantedBy=multi-user.target
- '
- dest: /usr/lib/systemd/system/maui.service
- group: root
- mode: 0644
- owner: root
- name: create maui.service file
- - shell: sleep 2
- - service: name={{MAUI_SERVICE}} state=started pattern=/usr/local/maui/sbin/maui
- - file: src=/etc/torque/nodes dest='{{TORQUE_PATH}}/server_priv/nodes' owner=root group=root state=link
- name: create symlink
- - service: name={{TORQUE_SERVICE}} state=restarted pattern=/usr/sbin/pbs_server
- - copy:
- content: '#!/bin/sh
- # es. qsub -l nodes=2 test.job
- #PBS -S /bin/sh
- #PBS -N ExampleJob
- #PBS -l walltime=00:01:00
- #PBS -q batch
- #PBS -o risultato
- #PBS -e errori
- DATE=`date`
- echo "$DATE"
- sleep 5
- echo "Ci sono una serie di cose interessanti che ti interessera sapere"
- echo "Questo job stato identificato come $PBS_JOBID e si chiama $PBS_JOBNAME"
- echo "e stato inserito inizialmente nella coda $PBS_O_QUEUE"
- echo "ed e stato eseguito sulla coda $PBS_QUEUE"
- echo "E stato sottoposto dalla macchina: $PBS_O_HOST"
- echo "E stato eseguito sulla macchina: `hostname`"
- date
- echo ""
- '
- dest: '/home/dteam001/test.job'
- mode: 0755
- owner: dteam001
- name: Create the test script
- @end
- )
- configure sudo_copy (
- @begin
- - local_action: command sudo cp {{src}} /tmp/._sudo_cp_{{ src | basename }}
- with_items: loop|default([0])
- - local_action: command sudo chmod +r /tmp/._sudo_cp_{{ src | basename }}
- with_items: loop|default([0])
- - copy:
- dest: '{{ dest }}'
- group: '{{ group | default(None) }}'
- mode: '{{ mode | default(None) }}'
- owner: '{{ owner | default(None) }}'
- src: /tmp/._sudo_cp_{{ src | basename }}
- with_items: loop|default([0])
- @end
- )
- configure munge_repo_front (
- @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 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
- FIREWALL_SERVICE: iptables
- @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
- FIREWALL_SERVICE: firewalld
- @end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement