Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hpc-team/HPCasCode
  • chines/ansible_cluster_in_a_box
2 results
Show changes
Showing
with 497 additions and 34 deletions
---
-
---
-
include: buildCA.yml
---
---
- name: "Check client ca certificate"
register: ca_cert
stat: "path={{ x509_cacert_file }}"
sudo: true
become: true
- name: "Check certificate and key"
shell: (openssl x509 -noout -modulus -in {{ x509_cert_file }} | openssl md5 ; openssl rsa -noout -modulus -in {{ x509_key_file }} | openssl md5) | uniq | wc -l
register: certcheck
sudo: true
become: true
- name: "Check certificate"
register: cert
stat: "path={{ x509_cert_file }}"
sudo: true
become: true
- name: "Check key"
register: key
stat: "path={{ x509_key_file }}"
sudo: true
become: true
- name: "Default: we don't need a new certificate"
set_fact: needcert=False
......@@ -31,11 +31,11 @@
when: cert.stat.exists == false or cert.stat.size == 0
- name: "Delete Zero Sized Ceritificates"
remote_user: "{{ hostvars[x509_ca_server]['ansible_ssh_user'] }}"
remote_user: "{{ hostvars[x509_ca_server]['ansible_user'] }}"
delegate_to: "{{ x509_ca_server }}"
shell: rm -rf /etc/easy-rsa/2.0/keys/{{ x509_common_name }}.*
when: cert is defined and cert.stat.size == 0
sudo: true
become: true
- name: "set needcert if cert doesn't match key"
set_fact: needcert=True
......@@ -49,7 +49,7 @@
- name: "Creating CSR"
shell: "cd /etc/easy-rsa/2.0; . ./vars; export EASY_RSA=\"${EASY_RSA:-.}\"; \"$EASY_RSA\"/pkitool --csr {{ x509_csr_args }} {{ x509_common_name }}"
when: needcert
sudo: true
become: true
- name: "Create node tmp directory"
delegate_to: 127.0.0.1
......@@ -57,57 +57,57 @@
- name: "Copy CSR to ansible host"
fetch: "src=/etc/easy-rsa/2.0/keys/{{ x509_common_name }}.csr dest=/tmp/{{ inventory_hostname }}/{{ inventory_hostname }}.csr fail_on_missing=yes validate_md5=yes flat=yes"
sudo: true
become: true
when: needcert
- name: "Copy CSR to CA"
remote_user: "{{ hostvars[x509_ca_server]['ansible_ssh_user'] }}"
remote_user: "{{ hostvars[x509_ca_server]['ansible_user'] }}"
delegate_to: "{{ x509_ca_server }}"
copy: "src=/tmp/{{ inventory_hostname }}/{{ inventory_hostname }}.csr dest=/etc/easy-rsa/2.0/keys/{{ x509_common_name }}.csr force=yes"
when: needcert
sudo: true
become: true
- name: "Sign Certificate"
remote_user: "{{ hostvars[x509_ca_server]['ansible_ssh_user'] }}"
remote_user: "{{ hostvars[x509_ca_server]['ansible_user'] }}"
delegate_to: "{{ x509_ca_server }}"
shell: "cd /etc/easy-rsa/2.0; . ./vars; export EASY_RSA=\"${EASY_RSA:-.}\" ;\"$EASY_RSA\"/pkitool --sign {{ x509_sign_args }} {{ x509_common_name }}"
when: needcert
sudo: true
become: true
- name: "Copy the Certificate to ansible host"
remote_user: "{{ hostvars[x509_ca_server]['ansible_ssh_user'] }}"
remote_user: "{{ hostvars[x509_ca_server]['ansible_user'] }}"
delegate_to: "{{ x509_ca_server }}"
fetch: "src=/etc/easy-rsa/2.0/keys/{{ x509_common_name }}.crt dest=/tmp/{{ inventory_hostname }}/{{ x509_common_name }}.crt fail_on_missing=yes validate_md5=yes flat=yes"
sudo: true
become: true
when: needcert
- name: "Copy the CA Certificate to the ansible host"
remote_user: "{{ hostvars[x509_ca_server]['ansible_ssh_user'] }}"
remote_user: "{{ hostvars[x509_ca_server]['ansible_user'] }}"
delegate_to: "{{ x509_ca_server }}"
fetch: "src=/etc/easy-rsa/2.0/keys/ca.crt dest=/tmp/{{ inventory_hostname }}/ca.crt fail_on_missing=yes validate_md5=yes flat=yes"
sudo: true
become: true
when: "ca_cert.stat.exists == false"
- name: "Make sure the path to the certificate exists"
shell: "mkdir -p `dirname {{ x509_cert_file }}` ; chmod 755 `dirname {{ x509_cert_file }}`"
sudo: true
become: true
- name: "Copy the certificate to the node"
copy: "src=/tmp/{{ inventory_hostname }}/{{ x509_common_name }}.crt dest=/tmp/{{ x509_common_name }}.crt force=yes"
sudo: true
become: true
when: needcert
- name: "Copy the certificate to the right location"
shell: "cp -f /tmp/{{ x509_common_name }}.crt {{ x509_cert_file }}"
sudo: true
become: true
when: needcert
- name: "Copy the CA certificate to the node"
copy: "src=/tmp/{{ inventory_hostname }}/ca.crt dest={{ x509_cacert_file }}"
sudo: true
become: true
when: "ca_cert.stat.exists == false"
- name: "Copy the key to the correct location"
shell: "mkdir -p `dirname {{ x509_key_file }}` ; chmod 700 `dirname {{ x509_key_file }}` ; cp /etc/easy-rsa/2.0/keys/{{ x509_common_name }}.key {{ x509_key_file }}"
sudo: true
become: true
when: needcert
---
-
---
-
include: buildCert.yml
readme.txt
\ No newline at end of file
readme.txt
\ No newline at end of file
......@@ -5,4 +5,4 @@ cityName: "Melbourne"
organizationName: "Monash University"
emailAddress: "default@default.org"
organizationUnit: "defaultUnit"
keySize: "512"
---
---
- name: "Copy the configuration file"
template: src={{ item }} dest=/etc/easy-rsa/2.0/vars mode=0644 owner=root
with_first_found:
......@@ -17,4 +17,4 @@
args:
chdir: "/etc/easy-rsa/2.0"
creates: "/etc/easy-rsa/2.0/keys"
sudo: true
become: true
---
-
name: "Installing easy-rsa"
yum: "name=easy-rsa state=latest"
sudo: True
when: ansible_os_family == 'RedHat'
-
name: "Installing easy-rsa"
apt: "name=openvpn state=present update_cache=yes"
sudo: True
when: ansible_os_family == 'Debian'
-
name: "Moving easy-rsa to /etc"
shell: "cp -rf /usr/share/easy-rsa /etc/"
args:
creates: /etc/easy-rsa
sudo: True
when: ansible_os_family == 'RedHat'
-
---
-
name: Download easy-rsa 2.2.2
get_url: url=https://github.com/OpenVPN/easy-rsa/archive/2.2.2.tar.gz dest=/tmp/2.2.2.tar.gz
-
name: Untar the source
shell: tar xvfz 2.2.2.tar.gz chdir=/tmp creates=/tmp/easy-rsa-2.2.2
-
name: "Moving easy-rsa to /etc"
shell: "cp -rf /usr/share/doc/openvpn/examples/easy-rsa /etc/"
args:
creates: /etc/easy-rsa
shell: cp -rf /tmp/easy-rsa-2.2.2/easy-rsa /etc/ creates=/etc/easy-rsa
sudo: True
when: ansible_os_family == 'Debian'
register: installed
- name: "Clean all"
......@@ -30,4 +17,5 @@
args:
creates: "/etc/easy-rsa/2.0/keys/"
when: installed|changed
sudo: true
become: true
---
-
include: installEasyRsa.yml
include: installEasyRsaSource.yml
-
include: copyConfigurationFile.yml
......@@ -3,11 +3,15 @@
name: "Install these yum packages"
with_items:
- gcc
- rsync
- make
- tcsh
- bind-utils
- openssl-devel
- nfs-utils
yum: "name={{ item }} state=present"
sudo: true
become: true
-
name: "Setting hostname"
shell: sysctl kernel.hostname={{ inventory_hostname }}
sudo: True
-
name: "Restarting Network"
service: name=network state=restarted
- name: Add ansible_user to systems group locally
user:
name: "{{ ansible_user }}"
groups: systems
append: yes
become: true
become_user: root
---
- name: make sure environment modules are installed
package:
name: environment-modules
state: present
become: true
when: default_modules == "modulecmd"
- name: template lmod bash
template: src=lmod_{{ ansible_os_family }}.sh.j2 dest=/etc/profile.d/lmod.sh
become: true
become_user: root
when: default_modules == "lmod"
- name: template lmod csh
template: src=lmod_{{ ansible_os_family }}.csh.j2 dest=/etc/profile.d/lmod.csh
become: true
become_user: root
when: default_modules == "lmod"
- name: remove modulecmd bash
file: path=/etc/profile.d/zz_modulecmd.sh state=absent
become: true
become_user: root
when: default_modules == "lmod"
- name: remove modulcmd csh
file: path=/etc/profile.d/zz_modulecmd.csh state=absent
become: true
become_user: root
when: default_modules == "lmod"
# vars:
# MODULESHOMEvar: '/usr/share/modules'
#note, alias profile here is over written
- name: template modulecmd bash
template: src=modulecmd.sh.j2 dest=/etc/profile.d/zz_runlast_modulecmd.sh
become: true
become_user: root
when: default_modules == "modulecmd"
#simon: this is to redefine bash `module` function as it is overwritten in module.sh
#- name: template patchmodulecmd bash
# template: src=patchmodulecmd.sh.j2 dest=/etc/profile.d/patchmodulecmd.sh
# become: true
# become_user: root
# when: default_modules == "modulecmd"
- name: delete anachronistic file simon to remove later
file:
path: /etc/profile.d/patchmodulecmd.sh.j2
state: absent
become: true
become_user: root
ignore_errors: true
- name: template modulecmd csh
template: src=modulecmd.csh.j2 dest=/etc/profile.d/zz_runlast_modulecmd.csh
become: true
become_user: root
when: default_modules == "modulecmd"
- name: remove lmod bash
file: path=/etc/profile.d/lmod.sh state=absent
become: true
become_user: root
when: default_modules == "modulecmd"
- name: remove modulcmd csh
file: path=/etc/profile.d/lmod.csh state=absent
become: true
become_user: root
when: default_modules == "modulecmd"
- name: Create a symbolic link
file:
src: /usr/share/modules
dest: /usr/share/Modules
owner: root
group: root
state: link
mode: u=rwx,g=rx,o=rx
become: true
when: ansible_os_family == 'Debian' and default_modules == 'modulecmd'
- name: load modulecmd in /etc/bash.bashrc this is to get module command to work from terminal on the desktop
lineinfile:
path: /etc/bash.bashrc
line: 'if [ -f /etc/profile.d/modulecmd.sh ]; then source /etc/profile.d/modulecmd.sh; fi'
become: true
when: ansible_os_family=="Debian" and default_modules == 'modulecmd'
#!/bin/csh
# -*- shell-script -*-
########################################################################
# This is the system wide source file for setting up
# modules:
#
########################################################################
set MY_NAME="{{ lmoddir }}/lmod/lmod/init/cshrc"
if ( ! $?MODULEPATH_ROOT ) then
if ( $?USER) then
setenv USER $LOGNAME
endif
set UNAME = `uname`
setenv LMOD_sys $UNAME
setenv LMOD_arch `uname -m`
if ( "x$UNAME" == xAIX ) then
setenv LMOD_arch rs6k
endif
setenv TARG_TITLE_BAR_PAREN " "
setenv LMOD_FULL_SETTARG_SUPPORT no
setenv LMOD_SETTARG_CMD :
setenv LMOD_COLORIZE yes
setenv LMOD_PREPEND_BLOCK normal
setenv MODULEPATH_ROOT "{{ lmoddir }}/modulefiles"
setenv MODULEPATH `{{ lmoddir }}/lmod/lmod/libexec/addto --append MODULEPATH $MODULEPATH_ROOT/$LMOD_sys $MODULEPATH_ROOT/Core`
setenv MODULEPATH `{{ lmoddir }}/lmod/lmod/libexec/addto --append MODULEPATH {{ lmoddir }}/lmod/lmod/modulefiles/Core`
setenv MODULEPATH "/usr/local/Modules/modulefiles"
setenv MODULESHOME "{{ lmoddir }}/lmod/lmod"
setenv BASH_ENV "$MODULESHOME/init/bash"
#
# If MANPATH is empty, Lmod is adding a trailing ":" so that
# the system MANPATH will be found
if ( ! $?MANPATH ) then
setenv MANPATH :
endif
setenv MANPATH `{{ lmoddir }}/lmod/lmod/libexec/addto MANPATH {{ lmoddir }}/lmod/lmod/share/man`
endif
if ( -f {{ lmoddir }}/lmod/lmod/init/csh ) then
source {{ lmoddir }}/lmod/lmod/init/csh
endif
lmod.csh.j2
\ No newline at end of file
#!/bin/sh
# -*- shell-script -*-
########################################################################
# This is the system wide source file for setting up
# modules:
#
########################################################################
if [ -z "${USER_IS_ROOT:-}" ]; then
if [ -z "${MODULEPATH_ROOT:-}" ]; then
export USER=${USER-${LOGNAME}} # make sure $USER is set
export LMOD_sys=`uname`
LMOD_arch=`uname -m`
if [ "x$LMOD_sys" = xAIX ]; then
LMOD_arch=rs6k
fi
export LMOD_arch
export MODULEPATH_ROOT="/usr/modulefiles:/usr/local/Modulefiles"
export LMOD_SETTARG_CMD=":"
export LMOD_FULL_SETTARG_SUPPORT=no
export LMOD_COLORIZE=yes
export LMOD_PREPEND_BLOCK=normal
MODULEPATH=`sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' /etc/lmod/modulespath`
export MODULEPATH=/usr/local/Modules/modulefiles/:$MODULEPATH
export MODULESHOME=/usr/share/lmod/lmod
export BASH_ENV=$MODULESHOME/init/bash
#
# If MANPATH is empty, Lmod is adding a trailing ":" so that
# the system MANPATH will be found
if [ -z "${MANPATH:-}" ]; then
export MANPATH=:
fi
export MANPATH=$(/usr/share/lmod/lmod/libexec/addto MANPATH /usr/share/lmod/lmod/share/man)
fi
PS_CMD=/bin/ps
if [ ! -x $PS_CMD ]; then
if [ -x /bin/ps ]; then
PS_CMD=/bin/ps
elif [ -x /usr/bin/ps ]; then
PS_CMD=/usr/bin/ps
fi
fi
EXPR_CMD=/usr/bin/expr
if [ ! -x $EXPR_CMD ]; then
if [ -x /usr/bin/expr ]; then
EXPR_CMD=/usr/bin/expr
elif [ -x /bin/expr ]; then
EXPR_CMD=/bin/expr
fi
fi
BASENAME_CMD=/usr/bin/basename
if [ ! -x $BASENAME_CMD ]; then
if [ -x /bin/basename ]; then
BASENAME_CMD=/bin/basename
elif [ -x /usr/bin/basename ]; then
BASENAME_CMD=/usr/bin/basename
fi
fi
my_shell=$($PS_CMD -p $$ -ocomm=)
my_shell=$($EXPR_CMD "$my_shell" : '-*\(.*\)')
my_shell=$($BASENAME_CMD $my_shell)
if [ -f /usr/share/lmod/lmod/init/$my_shell ]; then
. /usr/share/lmod/lmod/init/$my_shell >/dev/null # Module Support
else
. /usr/share/lmod/lmod/init/sh >/dev/null # Module Support
fi
unset my_shell PS_CMD EXPR_CMD BASENAME_CMD
fi
# Local Variables:
# mode: shell-script
# indent-tabs-mode: nil
# End:
lmod.csh.j2
\ No newline at end of file
#!/bin/bash
# -*- shell-script -*-
LMOD_PKG={{ lmoddir}}/lmod/lmod
LMOD_DIR={{ lmoddir }}/lmod/lmod/libexec
LMOD_CMD={{ lmoddir }}/lmod/lmod/libexec/lmod
MODULESHOME={{ lmoddir }}/lmod/lmod
MODULEPATH=/usr/local/Modules/modulefiles
export LMOD_PKG
export LMOD_CMD
export LMOD_DIR
export MODULESHOME
########################################################################
# Define the module command: The first line runs the "lmod" command
# to generate text:
# export PATH="..."
# then the "eval" converts the text into changes in the current shell.
#
# The second command is the settarg command. Normally LMOD_SETTARG_CMD
# is undefined or is ":". Either way the eval does nothing. When the
# settarg module is loaded, it defines LMOD_SETTARG_CMD. The settarg
# command knows how to read the ModuleTable that Lmod maintains and
# generates a series of env. vars that describe the current state of
# loaded modules. So if one is on a x86_64 linux computer with gcc/4.7.2
# and openmpi/1.6.3 loaded, then settarg will assign:
#
# TARG=_x86_64_gcc-4.7.2_openmpi-1.6.3
# TARG_COMPILER=gcc-4.7.2
# TARG_COMPILER_FAMILY=gcc
# TARG_MACH=x86_64
# TARG_MPI=openmpi-1.6.3
# TARG_MPI_FAMILY=openmpi
# TARG_SUMMARY=x86_64_gcc-4.7.2_openmpi-1.6.3
# TARG_TITLE_BAR=gcc-4.7.2 O-1.6.3
# TARG_TITLE_BAR_PAREN=(gcc-4.7.2 O-1.6.3)
#
# unloading openmpi/1.6.3 automatically changes these vars to be:
#
# TARG=_x86_64_gcc-4.6.3
# TARG_COMPILER=gcc-4.6.3
# TARG_COMPILER_FAMILY=gcc
# TARG_MACH=x86_64
# TARG_SUMMARY=x86_64_gcc-4.6.3
# TARG_TITLE_BAR=gcc-4.6.3
# TARG_TITLE_BAR_PAREN=(gcc-4.6.3)
#
# See Lmod web site for more details.
module()
{
eval $($LMOD_CMD bash "$@")
[ $? = 0 ] && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
}
if [ "${LMOD_SETTARG_CMD:-:}" != ":" ]; then
settarg () {
eval $(${LMOD_SETTARG_CMD:-:} -s sh "$@" )
}
fi
########################################################################
# ml is a shorthand tool for people who can't type moduel, err, module
# It is also a combination command:
# ml -> module list
# ml gcc -> module load gcc
# ml -gcc intel -> module unload gcc; module load intel
# It does much more do: "ml --help" for more information.
unalias ml > /dev/null 2>&1
ml()
{
eval $($LMOD_DIR/ml_cmd "$@")
}
export_module=$(echo "YES" | tr '[:upper:]' '[:lower:]')
if [ -n "$BASH_VERSION" -a "$export_module" != no ]; then
export -f module
export -f ml
fi
unset export_module
########################################################################
# clearMT removes the ModuleTable from your environment. It is rarely
# needed but it useful sometimes.
clearMT()
{
eval $($LMOD_DIR/clearMT_cmd bash)
}
########################################################################
# The following make the action of the settarg available to the titlebar
# for both xterm's and screen but only for interactive shells.
if [ "$PS1" ]; then
if [ -n "$LMOD_FULL_SETTARG_SUPPORT" -a "$LMOD_FULL_SETTARG_SUPPORT" != no ]; then
xSetTitleLmod()
{
builtin echo -n -e "\033]2;$1\007";
}
SET_TITLE_BAR=:
case $TERM in
xterm*)
SET_TITLE_BAR=xSetTitleLmod
;;
esac
SHOST=${SHOST-${HOSTNAME%%.*}}
precmd()
{
eval $(${LMOD_SETTARG_CMD:-:} -s bash)
${SET_TITLE_BAR:-:} "${TARG_TITLE_BAR_PAREN}${USER}@${SHOST}:${PWD/#$HOME/~}"
${USER_PROMPT_CMD:-:}
}
# define the PROMPT_COMMAND to be precmd iff it isn't defined already.
: ${PROMPT_COMMAND:=precmd}
fi
fi
########################################################################
# Make tab completions available to bash users.
if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r {{ lmoddir }}/lmod/lmod/init/lmod_bash_completions ] && [ -n "$PS1" ]; then
. {{ lmoddir }}/lmod/lmod/init/lmod_bash_completions
fi
if ($?tcsh) then
set modules_shell="tcsh"
else
set modules_shell="csh"
endif
set exec_prefix='/usr/bin'
set prefix=""
set postfix=""
if ( $?histchars ) then
set histchar = `echo $histchars | cut -c1`
set _histchars = $histchars
set prefix = 'unset histchars;'
set postfix = 'set histchars = $_histchars;'
else
set histchar = \!
endif
if ($?prompt) then
set prefix = "$prefix"'set _prompt="$prompt";set prompt="";'
set postfix = "$postfix"'set prompt="$_prompt";unset _prompt;'
endif
if ($?noglob) then
set prefix = "$prefix""set noglob;"
set postfix = "$postfix""unset noglob;"
endif
set postfix = "set _exit="'$status'"; $postfix; /usr/bin/test 0 = "'$_exit;'
alias module $prefix'eval `'$exec_prefix'/modulecmd '$modules_shell' '$histchar'*`; '$postfix
unset exec_prefix
unset prefix
unset postfix
setenv MODULESHOME /usr/share/Modules
if (! $?MODULEPATH ) then
setenv MODULEPATH `sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`:/usr/local/Modules/modulefiles
endif
if (! $?LOADEDMODULES ) then
setenv LOADEDMODULES ""
endif
module() { eval `/usr/bin/modulecmd bash $*`; /usr/local/bin/modulelog $*;}
export -f module
MODULESHOME=/usr/share/Modules
export MODULESHOME
if [ "${LOADEDMODULES:-}" = "" ]; then
LOADEDMODULES=
export LOADEDMODULES
fi
if [ "${MODULEPATH:-}" = "" ]; then
MODULEPATH=`sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`:/usr/local/Modules/modulefiles
export MODULEPATH
fi
if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r ${MODULESHOME}/init/bash_completion ]; then
. ${MODULESHOME}/init/bash_completion
fi
module() { eval `/usr/bin/modulecmd bash $*`; /usr/local/bin/modulelog $*;}
export -f module