Skip to content
Snippets Groups Projects
Commit 2d664537 authored by Cécile Cavet's avatar Cécile Cavet
Browse files

TP2 files

parent c725c36a
No related branches found
No related tags found
No related merge requests found
---
- hosts: worker
roles:
- { role: 'micafer.torque', torque_server: 'ansible-master', torque_type_of_node: 'mom' }
- hosts: master
roles:
- { role: 'micafer.torque', torque_server: 'ansible-master', torque_type_of_node: 'server' }
{#
IM - Infrastructure Manager
Copyright (C) 2011 - GRyCAP - Universitat Politecnica de Valencia
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% for host in groups['all'] %}
{{ hostvars[host]['ansible_hostname'] }} np={{ hostvars[host]['ansible_processor_vcpus'] }} num_node_boards=1
{% endfor %}
- include_vars: "{{ansible_os_family}}.yml"
# User creation, server actions
- name: Create User {{item.name}}
register: result
local_action: user uid={{item.id}} name={{item.name}} password={{item.password}} generate_ssh_key=yes shell=/bin/bash
with_items: USERS
ignore_errors: yes
- local_action: shell cp /home/{{item.name}}/.ssh/id_rsa.pub /tmp/{{item.name}}_id_rsa.pub creates=/tmp/{{item.name}}_id_rsa.pub
with_items: USERS
- name: Create User {{item.name}}
action: user uid={{item.id}} name={{item.name}} password={{item.password}} shell=/bin/bash
with_items: USERS
- name: Add the authorized_key to the user {{item.name}}
local_action: authorized_key user={{item.name}} key="{{ lookup('file', '/tmp/' + item.name + '_id_rsa.pub') }}"
with_items: USERS
#- template: src=ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
- name: check file epel.repo
stat: path=/etc/yum.repos.d/epel.repo
register: epel_repo
when: "ansible_os_family == 'RedHat'"
- name: create epel.repo
action: template src=epel.repo dest=/etc/yum.repos.d/epel.repo
when: "ansible_os_family == 'RedHat' and epel_repo.stat.exists == false"
- include: "{{torque_type_of_node}}.yml"
#- name: Open ports in the firewall
# command: iptables -I INPUT -p {{item}} --dport 15001:15004 -j ACCEPT
# ignore_errors: yes
# with_items:
# - tcp
# - udp
#- name: save iptables
# shell: iptables-save > /etc/sysconfig/iptables
# when: "ansible_os_family == 'RedHat'"
# to avoid errors if using this recipe without the IM
- wait_for: port=2049 delay=10 host={{ hostvars[groups['front'][0]]['ansible_eth0']['ipv4']['address'] }} timeout=300
when: "torque_type_of_node == 'mom' and not hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] is defined and hostvars[groups['front'][0]]['ansible_eth0']['ipv4']['address'] != ansible_eth0.ipv4.address"
ignore_errors: yes
- mount: name=/home src={{ hostvars[groups['front'][0]]['ansible_eth0']['ipv4']['address'] }}:/home fstype=nfs state=mounted
when: "torque_type_of_node == 'mom' and not hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] is defined and hostvars[groups['front'][0]]['ansible_eth0']['ipv4']['address'] != ansible_eth0.ipv4.address"
- wait_for: port=2049 delay=10 host={{ hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] }} timeout=300
when: "torque_type_of_node == 'mom' and hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] is defined and hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] != IM_NODE_NET_0_IP"
ignore_errors: yes
- mount: name=/home src={{ hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] }}:/home fstype=nfs state=mounted
when: "torque_type_of_node == 'mom' and hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] is defined and hostvars[groups['front'][0]]['IM_NODE_NET_0_IP'] != IM_NODE_NET_0_IP"
nodes=0
# RedHat related OSs
- name: Yum install torque-mom
action: yum pkg=torque-mom,nfs-utils state=installed
when: "ansible_os_family == 'RedHat'"
# Debian related OSs
- name: Apt install torque-mom
action: apt pkg=torque-mom,nfs-common state=installed update_cache=yes cache_valid_time=86400
when: "ansible_os_family == 'Debian'"
- copy: content={{torque_server}} dest=/etc/torque/server_name
notify:
- restart {{mom_service}}
- lineinfile: dest="{{torque_path}}/mom_priv/config" regexp=\$clienthost line='$clienthost {{torque_server}}' create=yes
notify:
- restart {{mom_service}}
- lineinfile: dest="{{torque_path}}/mom_priv/config" regexp=\$pbsserver line='$pbsserver {{torque_server}}'
notify:
- restart {{mom_service}}
- lineinfile: dest="{{torque_path}}/mom_priv/config" regexp=/home line='$usecp *:/home /home'
notify:
- restart {{mom_service}}
#- name: start {{mom_service}}
# service: name={{mom_service}} state=started pattern=/usr/sbin/pbs_mom
- name: Wait for munge to be installed on the server
local_action: wait_for path=/usr/sbin/create-munge-key
when: "ansible_os_family == 'RedHat'"
- name: Create munge key on the server
local_action: command /usr/sbin/create-munge-key creates=/etc/munge/munge.key
when: "ansible_os_family == 'RedHat'"
- copy: src=/etc/munge/munge.key dest=/etc/munge/munge.key owner=munge group=munge mode=0400
when: "ansible_os_family == 'RedHat'"
notify:
- restart munge
- name: start {{mom_service}}
service: name={{mom_service}} state=started pattern=/usr/sbin/pbs_mom
# RedHat related OSs
- name: Yum install {{ item }}
action: yum pkg={{ item }} state=installed
when: "ansible_os_family == 'RedHat'"
with_items:
- nfs-utils
- torque-server
- torque-scheduler
- torque-client
# Debian related OSs
- name: Apt install {{ item }}
action: apt pkg={{ item }} state=installed update_cache=yes cache_valid_time=86400
when: "ansible_os_family == 'Debian'"
with_items:
- nfs-kernel-server
- torque-server
- torque-scheduler
- torque-client
# NFS tasks
- service: name=rpcbind state=started enabled=yes
when: "ansible_os_family == 'RedHat'"
- service: name={{nfs_svc_name}} state=started enabled=yes
when: "ansible_os_family == 'RedHat'"
- service: name=nfslock state=started enabled=yes
when: "ansible_os_family == 'RedHat'"
- lineinfile: dest=/etc/exports regexp=^/home line="/home {{ groups.wn | join("(rw,sync,no_root_squash,no_subtree_check) ") }}"(rw,sync,no_root_squash,no_subtree_check)
when: groups.wn is defined
- name: export exports file
command: exportfs -ra
#- name: Open ports in the firewall for NFS
# command: iptables -I INPUT -p {{ item[1] }} --dport {{ item[0] }}:{{ item[0] }} -j ACCEPT
# ignore_errors: yes
# with_nested:
# - [ '111', '2049' ]
# - [ 'tcp', 'udp' ]
- name: Restart NFS server
service: name=nfs state=restarted
#Torque tasks
- copy: content={{torque_server}} dest=/etc/torque/server_name
notify:
- restart {{server_service}}
- restart {{scheduler_service}}
- template: src=hosts.conf dest={{torque_path}}/server_priv/nodes
notify:
- restart {{server_service}}
- restart {{scheduler_service}}
- template: src=ssh_known_hosts.conf dest=/etc/ssh/ssh_known_hosts
- command: /usr/sbin/create-munge-key creates=/etc/munge/munge.key
when: "ansible_os_family == 'RedHat'"
notify:
- restart munge
- file: path=/etc/munge/munge.key owner=munge group=munge mode=0400
when: "ansible_os_family == 'RedHat'"
notify:
- restart munge
- service: name=trqauthd state=started pattern=/usr/sbin/trqauthd
- service: name={{scheduler_service}} state=started pattern=/usr/sbin/pbs_sched
- service: name={{server_service}} state=started pattern=/usr/sbin/pbs_server
- service: name=munge state=started
when: "ansible_os_family == 'RedHat'"
- shell: echo "{{ lookup('file', 'queue.txt') }}" | qmgr creates={{torque_path}}/server_priv/queues/batch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment