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
  • rc/hpc-factory
  • louistw/hpc-factory
  • jpr/hpc-factory
  • krish94/hpc-factory
  • atlurie/hpc-factory
  • dwheel7/hpc-factory
  • jpr/vm-factory
  • rc/vm-factory
  • krish94/vm-factory
9 results
Show changes
Showing
with 1002 additions and 8 deletions
---
- name: nfs_mounts using fstab
include_tasks: fstab.yml
when: not use_autofs
when: use_fstab
- name: nfs_mounts using autofs
include_tasks: autofs.yml
......
const fs = require('fs');
const http = require('http');
const path = require('path');
const WebSocket = require('ws');
const express = require('express');
const pty = require('node-pty');
const hbs = require('hbs');
const dotenv = require('dotenv');
const Tokens = require('csrf');
const url = require('url');
const yaml = require('js-yaml');
const glob = require('glob');
const port = 3000;
const host_path_rx = '/ssh/([^\\/\\?]+)([^\\?]+)?(\\?.*)?$';
const helpers = require('./utils/helpers');
const pingInterval = 30000;
// Read in environment variables
dotenv.config({path: '.env.local'});
if (process.env.NODE_ENV === 'production') {
dotenv.config({path: '/etc/ood/config/apps/shell/env'});
}
// Keep app backwards compatible
if (fs.existsSync('.env')) {
console.warn('[DEPRECATION] The file \'.env\' is being deprecated. Please move this file to \'/etc/ood/config/apps/shell/env\'.');
dotenv.config({path: '.env'});
}
// Load color themes
var color_themes = {dark: [], light: []};
glob.sync('./color_themes/light/*').forEach(f => color_themes.light.push(require(path.resolve(f))));
glob.sync('./color_themes/dark/*').forEach(f => color_themes.dark.push(require(path.resolve(f))));
color_themes.json_array = JSON.stringify([...color_themes.light, ...color_themes.dark]);
const tokens = new Tokens({});
const secret = tokens.secretSync();
// Create all your routes
var router = express.Router();
router.get(['/', '/ssh'], function (req, res) {
res.redirect(req.baseUrl + '/ssh/default');
});
router.get('/ssh*', function (req, res) {
var theHost, theDir;
[theHost, theDir] = host_and_dir_from_url(req.url);
res.render('index',
{
baseURI: req.baseUrl,
csrfToken: tokens.create(secret),
host: theHost,
dir: theDir,
colorThemes: color_themes,
siteTitle: (process.env.OOD_DASHBOARD_TITLE || "Open OnDemand"),
});
});
router.use(express.static(path.join(__dirname, 'public')));
// Setup app
var app = express();
// Setup template engine
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'views'));
// Mount the routes at the base URI
app.use(process.env.PASSENGER_BASE_URI || '/', router);
// Setup websocket server
const server = new http.createServer(app);
const wss = new WebSocket.Server({ noServer: true });
let host_allowlist = new Set;
if (process.env.OOD_SSHHOST_ALLOWLIST){
host_allowlist = new Set(process.env.OOD_SSHHOST_ALLOWLIST.split(':'));
}
let default_sshhost, first_available_host;
glob.sync(path.join((process.env.OOD_CLUSTERS || '/etc/ood/config/clusters.d'), '*.y*ml'))
.map(yml => {
try {
return yaml.safeLoad(fs.readFileSync(yml));
} catch(err) { /** just keep going. dashboard should have an alert about it */}
})
.filter(config => (config && config.v2 && config.v2.login && config.v2.login.host) && ! (config.v2 && config.v2.metadata && config.v2.metadata.hidden))
.forEach((config) => {
let host = config.v2.login.host; //Already did checking above
let isDefault = config.v2.login.default;
host_allowlist.add(host);
if (isDefault) default_sshhost = host;
if (!first_available_host) first_available_host = host;
});
default_sshhost = process.env.OOD_DEFAULT_SSHHOST || process.env.DEFAULT_SSHHOST || default_sshhost || first_available_host;
if (default_sshhost) host_allowlist.add(default_sshhost);
function host_and_dir_from_url(url){
let match = url.match(host_path_rx),
hostname = null,
directory = null;
if (match) {
hostname = match[1] === "default" ? default_sshhost : match[1];
directory = match[2] ? decodeURIComponent(match[2]) : null;
}
return [hostname, directory];
}
function heartbeat() {
this.isAlive = true;
}
wss.on('connection', function connection (ws, req) {
var dir,
term,
args,
host,
cmd = process.env.OOD_SSH_WRAPPER || 'ssh';
ws.isAlive = true;
ws.on('pong', heartbeat);
console.log('Connection established');
[host, dir] = host_and_dir_from_url(req.url);
args = dir ? [host, '-t', 'cd \'' + dir.replace(/\'/g, "'\\''") + '\' ; exec ${SHELL} -l'] : [host];
process.env.LANG = 'en_US.UTF-8'; // this patch (from b996d36) lost when removing wetty (2c8a022)
term = pty.spawn(cmd, args, {
name: 'xterm-16color',
cols: 80,
rows: 30
});
console.log('Opened terminal: ' + term.pid);
term.on('data', function (data) {
ws.send(data, function (error) {
if (error) console.log('Send error: ' + error.message);
});
});
term.on('error', function (error) {
ws.close();
});
term.on('close', function () {
ws.close();
});
ws.on('message', function (msg) {
msg = JSON.parse(msg);
if (msg.input) term.write(msg.input);
if (msg.resize) term.resize(parseInt(msg.resize.cols), parseInt(msg.resize.rows));
});
ws.on('close', function () {
term.end();
console.log('Closed terminal: ' + term.pid);
});
});
const interval = setInterval(function ping() {
wss.clients.forEach(function each(ws) {
if (ws.isAlive === false) return ws.terminate();
ws.isAlive = false;
ws.ping();
});
}, pingInterval);
function custom_server_origin(default_value = null){
var custom_origin = null;
if(process.env.OOD_SHELL_ORIGIN_CHECK) {
// if ENV is set, do not use default!
if(process.env.OOD_SHELL_ORIGIN_CHECK.startsWith('http')){
custom_origin = process.env.OOD_SHELL_ORIGIN_CHECK;
}
}
else {
custom_origin = default_value;
}
return custom_origin;
}
function default_server_origin(headers){
var origin = null;
if (headers['x-forwarded-proto'] && headers['x-forwarded-host']){
origin = headers['x-forwarded-proto'] + "://" + headers['x-forwarded-host']
}
return origin;
}
server.on('upgrade', function upgrade(request, socket, head) {
const requestToken = new URLSearchParams(url.parse(request.url).search).get('csrf'),
client_origin = request.headers['origin'],
server_origin = custom_server_origin(default_server_origin(request.headers));
var host, dir;
[host, dir] = host_and_dir_from_url(request.url);
if (client_origin &&
client_origin.startsWith('http') &&
server_origin && client_origin !== server_origin) {
socket.write([
'HTTP/1.1 401 Unauthorized',
'Content-Type: text/html; charset=UTF-8',
'Content-Encoding: UTF-8',
'Connection: close',
'X-OOD-Failure-Reason: invalid origin',
].join('\r\n') + '\r\n\r\n');
socket.destroy();
} else if (!tokens.verify(secret, requestToken)) {
socket.write([
'HTTP/1.1 401 Unauthorized',
'Content-Type: text/html; charset=UTF-8',
'Content-Encoding: UTF-8',
'Connection: close',
'X-OOD-Failure-Reason: bad csrf token',
].join('\r\n') + '\r\n\r\n');
socket.destroy();
} else if (!helpers.hostInAllowList(host_allowlist, host)) { // host not in allowlist
socket.write([
'HTTP/1.1 401 Unauthorized',
'Content-Type: text/html; charset=UTF-8',
'Content-Encoding: UTF-8',
'Connection: close',
'X-OOD-Failure-Reason: host not specified in allowlist or cluster configs',
].join('\r\n') + '\r\n\r\n');
socket.destroy();
} else {
wss.handleUpgrade(request, socket, head, function done(ws) {
wss.emit('connection', ws, request);
});
}
});
server.listen(port, function () {
console.log('Listening on ' + port);
});
---
- name: Config ood to run behind proxy
ansible.builtin.template:
src: ood_proxy.conf.j2
dest: /opt/rh/httpd24/root/etc/httpd/conf.d/ood-proxy.conf
- name: Patch shell app with shell timeout fix
ansible.builtin.copy:
src: shell-app.js
dest: /var/www/ood/apps/sys/shell/app.js
- name: Create a directory if it does not exist
ansible.builtin.file:
path: /etc/ood/config/apps/shell
state: directory
mode: "0755"
- name: Shell app configuration env
ansible.builtin.template:
src: shell_app.env.j2
dest: /etc/ood/config/apps/shell/env
- name: Point shell app to login node
ansible.builtin.replace:
path: /etc/ood/config/clusters.d/{{ cluster_name }}.yml
regexp: '^(\s+host:).*'
replace: '\1 "{{ login_hostname }}"'
backup: yes
- name: Modify account app binding to listen to http-proxy
ansible.builtin.lineinfile:
path: /var/www/ood/register/{{account_app}}/{{account_app}}.ini
regexp: '^(bind\s=).*'
line: "bind = {{ account_app_bind_address }}"
- name: Restart httpd24-httpd
ansible.builtin.service:
name: httpd24-httpd
state: restarted
#
# Open OnDemand Portal
#
# Generated using ood-portal-generator version 0.8.0
#
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !! !!
# !! DO NOT EDIT THIS FILE !!
# !! !!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# This file is auto-generated by ood-portal-generator and will be over-written
# in future updates.
#
# 1. To modify this file, first update the global configuration file:
#
# /etc/ood/config/ood_portal.yml
#
# You can find more information about the ood-portal-generator configuration
# at:
#
# https://osc.github.io/ood-documentation/master/infrastructure/ood-portal-generator.html
#
# 2. Then build/install the updated Apache config with:
#
# sudo /opt/ood/ood-portal-generator/sbin/update_ood_portal
#
# 3. Finally, restart Apache to have the changes take effect:
#
# # For CentOS 6
# sudo service httpd24-httpd condrestart
# sudo service httpd24-htcacheclean condrestart
#
# # For CentOS 7
# sudo systemctl try-restart httpd24-httpd.service httpd24-htcacheclean.service
#
# The Open OnDemand portal VirtualHost
#
<VirtualHost {{ ood_internal_ip }}:80>
ServerName {{ ood_hostname }}
ErrorLog "logs/{{ ood_hostname }}_error.log"
CustomLog "logs/{{ ood_hostname }}_access.log" combined
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(rc.uab.edu(:80)?)?$ [NC]
RewriteRule ^(.*) http://rc.uab.edu:80$1 [R=301,NE,L]
# Lua configuration
#
LuaRoot "/opt/ood/mod_ood_proxy/lib"
LogLevel lua_module:info
# Log authenticated user requests (requires min log level: info)
LuaHookLog logger.lua logger
# Authenticated-user to system-user mapping configuration
#
SetEnv OOD_USER_MAP_CMD "/opt/ood/ood_auth_map/bin/user_auth.py"
SetEnv OOD_USER_ENV "REMOTE_USER"
SetEnv OOD_MAP_FAIL_URI "/account"
# Per-user Nginx (PUN) configuration
# NB: Apache will need sudo privs to control the PUNs
#
SetEnv OOD_PUN_STAGE_CMD "sudo /opt/ood/nginx_stage/sbin/nginx_stage"
#
# Below is used for sub-uri's this Open OnDemand portal supports
#
# Serve up publicly available assets from local file system:
#
# http://{{ ood_hostname }}:80/public/favicon.ico
# #=> /var/www/ood/public/favicon.ico
#
Alias "/public" "/var/www/ood/public"
<Directory "/var/www/ood/public">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Reverse proxy traffic to backend webserver through IP sockets:
#
# http://{{ ood_hostname }}:80/node/HOST/PORT/index.html
# #=> http://HOST:PORT/node/HOST/PORT/index.html
#
<LocationMatch "^/node/(?<host>c\d+)/(?<port>\d+)">
RewriteCond %{IS_SUBREQ} ^false$
RewriteCond %{HTTP:Proxy-user} "([^!]+?)(@uab.edu)?$"
RewriteRule . - [E=REMOTE_USER:%1]
# ProxyPassReverse implementation
Header edit Location "^[^/]+//[^/]+" ""
# ProxyPassReverseCookieDomain implemenation
Header edit* Set-Cookie ";\s*(?i)Domain[^;]*" ""
# ProxyPassReverseCookiePath implementation
Header edit* Set-Cookie ";\s*(?i)Path[^;]*" ""
Header edit Set-Cookie "^([^;]+)" "$1; Path=/node/%{MATCH_HOST}e/%{MATCH_PORT}e"
LuaHookFixups node_proxy.lua node_proxy_handler
</LocationMatch>
# Reverse "relative" proxy traffic to backend webserver through IP sockets:
#
# http://{{ ood_hostname }}:80/rnode/HOST/PORT/index.html
# #=> http://HOST:PORT/index.html
#
<LocationMatch "^/rnode/(?<host>c\d+)/(?<port>\d+)(?<uri>/.*|)">
RewriteCond %{IS_SUBREQ} ^false$
RewriteCond %{HTTP:Proxy-user} "([^!]+?)(@uab.edu)?$"
RewriteRule . - [E=REMOTE_USER:%1]
# ProxyPassReverse implementation
Header edit Location "^([^/]+//[^/]+)|(?=/)" "/rnode/%{MATCH_HOST}e/%{MATCH_PORT}e"
# ProxyPassReverseCookieDomain implemenation
Header edit* Set-Cookie ";\s*(?i)Domain[^;]*" ""
# ProxyPassReverseCookiePath implementation
Header edit* Set-Cookie ";\s*(?i)Path[^;]*" ""
Header edit Set-Cookie "^([^;]+)" "$1; Path=/rnode/%{MATCH_HOST}e/%{MATCH_PORT}e"
LuaHookFixups node_proxy.lua node_proxy_handler
</LocationMatch>
# Reverse proxy traffic to backend PUNs through Unix domain sockets:
#
# http://{{ ood_hostname }}:80/pun/dev/app/simulations/1
# #=> unix:/path/to/socket|http://localhost/pun/dev/app/simulations/1
#
SetEnv OOD_PUN_URI "/pun"
<Location "/pun">
RewriteCond %{IS_SUBREQ} ^false$
RewriteCond %{HTTP:Proxy-user} "([^!]+?)(@uab.edu)?$"
RewriteRule . - [E=REMOTE_USER:%1]
ProxyPassReverse "http://localhost/pun"
# ProxyPassReverseCookieDomain implementation (strip domain)
Header edit* Set-Cookie ";\s*(?i)Domain[^;]*" ""
# ProxyPassReverseCookiePath implementation (less restrictive)
Header edit* Set-Cookie ";\s*(?i)Path\s*=(?-i)(?!\s*/pun)[^;]*" "; Path=/pun"
SetEnv OOD_PUN_SOCKET_ROOT "/var/run/ondemand-nginx"
SetEnv OOD_PUN_MAX_RETRIES "5"
LuaHookFixups pun_proxy.lua pun_proxy_handler
</Location>
# Control backend PUN for authenticated user:
# NB: See mod_ood_proxy for more details.
#
# http://{{ ood_hostname }}:80/nginx/stop
# #=> stops the authenticated user's PUN
#
SetEnv OOD_NGINX_URI "/nginx"
<Location "/nginx">
RewriteCond %{IS_SUBREQ} ^false$
RewriteCond %{HTTP:Proxy-user} "([^!]+?)(@uab.edu)?$"
RewriteRule . - [E=REMOTE_USER:%1]
LuaHookFixups nginx.lua nginx_handler
</Location>
# Redirect root URI to specified URI
#
# http://{{ ood_hostname }}:80/
# #=> http://{{ ood_hostname }}:80/pun/sys/dashboard
#
RedirectMatch ^/$ "/pun/sys/dashboard"
# Redirect logout URI to specified redirect URI
#
# http://{{ ood_hostname }}:80/logout
# #=> http://{{ ood_hostname }}:80/pun/sys/dashboard/logout
#
Redirect "/logout" "/pun/sys/dashboard/logout"
# Register and/or unregister the mapping of an authenticated-user to a system-user
# NB: This is not needed for regular expression mapping
#
# http://{{ ood_hostname }}:80/account
# #=> /var/www/ood/register/
#
Alias "/account" "/var/www/ood/register"
<Directory "/var/www/ood/register">
Options Indexes FollowSymLinks
AllowOverride None
RewriteCond %{IS_SUBREQ} ^false$
RewriteCond %{HTTP:Proxy-user} "([^!]+?)(@uab.edu)?$"
RewriteRule . - [E=REMOTE_USER:%1]
</Directory>
</VirtualHost>
OOD_SHELL_ORIGIN_CHECK='{{ ood_domain }}'
---
- name: Add apache rewritemap script config
ansible.builtin.template:
src: rewrite_map_config_py.j2
mode: '600'
owner: root
group: root
dest: /var/www/rewrite_map_config.py
- name: Replace OOD rewrite condition regex in Apache configuration
ansible.builtin.replace:
path: /etc/httpd/conf.d/front-end.conf
regexp: "RewriteCond %{HTTP:REMOTE_USER} '\\^\\(\\.\\+\\)\\$'"
replace: |
RewriteCond %{HTTP:REMOTE_USER} '([a-zA-Z0-9_.+-]+)@uab.edu$' [OR]
RewriteCond %{HTTP:REMOTE_USER} 'urn:mace:incommon:uab.edu!https://uabgrid.uab.edu/shibboleth!(.+)$'
- name: Replace account app port in Apache configuration
ansible.builtin.replace:
path: /etc/httpd/conf.d/front-end.conf
regexp: "account-app:8000"
replace: "account-app:{{ account_app_port }}"
- name: Restart httpd services
ansible.builtin.service:
name: httpd
enabled: true
state: restarted
DEBUG = False
target_groups = {
{% for group in target_groups %}
"{{ group.name }}": "{{ group.host }}",
{% endfor %}
}
{% for group in target_groups %}
{% if group.default %}
default_hostname = "{{ group.host }}"
{% endif %}
{% endfor %}
---
- name: Add rsyslog configuration
ansible.builtin.template:
src: rsyslog.conf.j2
dest: /etc/rsyslog.conf
mode: 0644
owner: root
group: root
backup: true
- name: Enable and start rsyslog
ansible.builtin.service:
name: rsyslog
enabled: true
state: restarted
# rsyslog configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
# Added for distro update >= 4 (7u4)
global (
net.enabledns="off"
)
#### MODULES ####
# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
#$ModLoad imklog # reads kernel messages (the same are read from journald)
#$ModLoad immark # provides --MARK-- message capability
# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
# Provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Where to place auxiliary files
$WorkDirectory /var/lib/rsyslog
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf
# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on
# File to store the position in the journal
$IMJournalStateFile imjournal.state
#### RULES ####
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Filter nslcd ldap ldap_abandon and ldap_result messages.
if $programname == 'nslcd' and $syslogseverity >= '3' and $msg contains ' failed: Can\'t contact LDAP server' then stop
if $programname == 'nslcd' and $syslogseverity >= '3' and $msg contains 'ldap_abandon() failed to abandon search: Other (e.g., implementation specific) error' then stop
if $programname == 'nslcd' and $syslogseverity >= '3' and $msg contains 'ldap_abandon() failed to abandon search: Can\'t contact LDAP server: Transport endpoint is not connected' then stop
if $programname == 'nslcd' and $syslogseverity >= '3' and $msg contains 'no available LDAP server found, sleeping ' then stop
if $programname == 'nslcd' and $syslogseverity >= '3' and $msg contains 'connected to LDAP server ldap://local' then stop
# Filter sntp started messages.
if $programname == 'sntp' and $syslogseverity > '3' and $msg contains 'Started sntp' then stop
# MariaDB Galera
# disabled, as these messages are being generated every few seconds
:msg, contains, "START: cm-check-galera-status" stop
:msg, contains, "EXIT: cm-check-galera-status" stop
# HAProxy for OpenStack
if $syslogfacility-text == 'local4' and ($programname == 'haproxy') then {
local4.* /var/log/haproxy.log
stop
}
# OpenStack specific
if $syslogfacility-text == 'daemon' then {
# needed for proper handling of Python stack traces
$EscapeControlCharactersOnReceive off
if $programname startswith 'keystone' then {
*.* /var/log/keystone/keystone.log
}
if $programname startswith 'nova' then {
*.* /var/log/nova/nova.log
if $programname == 'nova-api' then {
*.* /var/log/nova/nova-api.log
}
if $programname == 'nova-scheduler' then {
*.* /var/log/nova/nova-scheduler.log
}
if $programname == 'nova-conductor' then {
*.* /var/log/nova/nova-conductor.log
}
if $programname == 'nova-novncproxy' then {
*.* /var/log/nova/nova-novncproxy.log
}
if $programname == 'nova-compute' then {
*.* /var/log/nova/nova-compute.log
}
}
if $programname startswith 'neutron' then {
*.* /var/log/neutron/neutron.log
if $programname == 'neutron-server' then {
*.* /var/log/neutron/neutron-server.log
}
if $programname == 'neutron-metadata-agent' then {
*.* /var/log/neutron/neutron-metadata-agent.log
}
if $programname == 'neutron-l3-agent' then {
*.* /var/log/neutron/neutron-l3-agent.log
}
if $programname == 'neutron-dhcp-agent' then {
*.* /var/log/neutron/neutron-dhcp-agent.log
}
if $programname == 'neutron-openvswitch-agent' then {
*.* /var/log/neutron/neutron-openvswitch-agent.log
}
}
if $programname startswith 'glance' then {
*.* /var/log/glance/glance.log
if $programname == 'glance-api' then {
*.* /var/log/glance/glance-api.log
}
if $programname == 'glance-registry' then {
*.* /var/log/glance/glance-registry.log
}
}
if $programname startswith 'cinder' then {
*.* /var/log/cinder/cinder.log
if $programname == 'cinder-api' then {
*.* /var/log/cinder/cinder-api.log
}
if $programname == 'cinder-scheduler' then {
*.* /var/log/cinder/cinder-scheduler.log
}
if $programname == 'cinder-volume' then {
*.* /var/log/cinder/cinder-volume.log
}
if $programname == 'cinder-backup' then {
*.* /var/log/cinder/cinder-backup.log
}
}
if $programname startswith 'heat' then {
*.* /var/log/heat/heat.log
if $programname == 'heat-api' then {
*.* /var/log/heat/heat-api.log
}
if $programname == 'heat-engine' then {
*.* /var/log/heat/heat-engine.log
}
}
if $programname startswith 'keystone' or \
$programname startswith 'nova' or \
$programname startswith 'neutron' or \
$programname startswith 'glance' or \
$programname startswith 'cinder' or \
$programname startswith 'heat' then {
*.* /var/log/openstack
*.* @master:514
stop
}
}
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none;local5.none;local6.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg :omusrmsg:*
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
# cm related log files:
local5.* -/var/log/node-installer
local6.* -/var/log/cmdaemon
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
#CM
{{ rsyslog_target }}
#### end of the forwarding rule ###
......@@ -19,6 +19,7 @@
state: present
uid: 450
group: slurm
create_home: false
- name: Copy munge key
ansible.builtin.copy:
......@@ -28,6 +29,19 @@
group: root
mode: 0400
- name: Create symbolic links for Slurm config files
ansible.builtin.file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: link
force: yes # Force the creation of the symlinks even if source files do not exist yet
loop:
- { src: "/cm/shared/apps/slurm/var/etc/cgroup.conf", dest: "/etc/slurm/cgroup.conf" }
- { src: "/cm/shared/apps/slurm/var/etc/gres.conf", dest: "/etc/slurm/gres.conf" }
- { src: "/cm/shared/apps/slurm/var/etc/slurm.conf", dest: "/etc/slurm/slurm.conf" }
- { src: "/cm/shared/apps/slurm/var/etc/slurmdbd.conf", dest: "/etc/slurm/slurmdbd.conf" }
- { src: "/cm/shared/apps/slurm/var/etc/job_submit.lua", dest: "/etc/slurm/job_submit.lua" }
- name: Enable services
ansible.builtin.service:
name: "{{ item }}"
......
---
- name: Ensure destination directory exists only if not present
ansible.builtin.file:
path: /tmp/ssh_keys
state: directory
mode: '0755'
- name: Install require package
ansible.builtin.pip:
name: boto3
extra_args: "--extra-index-url https://pypi.python.org/simple"
executable: "/usr/bin/pip3"
- name: Download SSH host keys tar.gz from S3
aws_s3:
mode: get
s3_url: "{{ S3_ENDPOINT }}"
bucket: "{{ SSH_HOST_KEYS_S3_BUCKET }}"
object: "{{ SSH_HOST_KEYS_S3_OBJECT }}"
dest: "/tmp/ssh_keys/{{ SSH_HOST_KEYS_S3_OBJECT }}"
aws_access_key: "{{ LTS_ACCESS_KEY }}"
aws_secret_key: "{{ LTS_SECRET_KEY }}"
vars:
ansible_python_interpreter: /usr/bin/python3
when: SSH_HOST_KEYS_S3_BUCKET | length > 0 and SSH_HOST_KEYS_S3_OBJECT | length > 0
- name: Unpack SSH host keys to /etc/ssh
ansible.builtin.unarchive:
src: "/tmp/ssh_keys/{{ SSH_HOST_KEYS_S3_OBJECT }}"
dest: "/etc/ssh"
group: root
owner: root
remote_src: yes
become: true
when: SSH_HOST_KEYS_S3_BUCKET | length > 0 and SSH_HOST_KEYS_S3_OBJECT | length > 0
- name: Remove the temporary folder after put in place
ansible.builtin.file:
path: /tmp/ssh_keys
state: absent
- name: Restart SSH service
ansible.builtin.service:
name: sshd
state: restarted
become: true
---
- name: Configure sshpiper yaml plugin
ansible.builtin.template:
src: sshpiperd.yaml.j2
dest: "{{ sshpiper_dest_dir }}/sshpiperd.yaml"
backup: true
- name: Enable and start sshpiper service
ansible.builtin.service:
name: sshpiperd
enabled: true
state: restarted
# yaml-language-server: $schema=https://raw.githubusercontent.com/tg123/sshpiper/master/plugin/yaml/schema.json
version: "1.0"
pipes:
{% for group in target_groups %}
{% if not group.default %}
- from:
- groupname: "{{ group.name }}"
authorized_keys: "{{ group.authorized_keys }}"
to:
host: "{{ group.host }}"
ignore_hostkey: true
private_key: "{{ group.private_key }}"
- from:
- groupname: "{{ group.name }}"
to:
host: "{{ group.host }}"
ignore_hostkey: true
{% else %}
- from:
- username: ".*" # catch all
username_regex_match: true
authorized_keys: "{{ group.authorized_keys }}"
to:
host: "{{ group.host }}"
ignore_hostkey: true
private_key: "{{ group.private_key }}"
- from:
- username: ".*"
username_regex_match: true
to:
host: "{{ group.host }}"
ignore_hostkey: true
{% endif %}
{% endfor %}
---
- name: Download SSL Certs from S3
aws_s3:
mode: get
s3_url: "{{ S3_ENDPOINT }}"
bucket: "{{ ssl_cert_s3_bucket }}"
object: "{{ item }}"
dest: "{{ ssl_cert_file_location }}/{{ item }}"
aws_access_key: "{{ LTS_ACCESS_KEY }}"
aws_secret_key: "{{ LTS_SECRET_KEY }}"
vars:
ansible_python_interpreter: /usr/bin/python3
when: ssl_cert_s3_bucket | length > 0 and item | length > 0
loop:
- "{{ ssl_cert_file }}"
- "{{ ssl_cert_chain_file }}"
- name: Change cert files permissions
ansible.builtin.file:
path: "{{ ssl_cert_file_location }}/{{ item }}"
owner: root
group: root
mode: '0600'
when: ssl_cert_s3_bucket | length > 0 and item | length > 0
loop:
- "{{ ssl_cert_file }}"
- "{{ ssl_cert_chain_file }}"
- name: Download SSL key from S3
aws_s3:
mode: get
s3_url: "{{ S3_ENDPOINT }}"
bucket: "{{ ssl_cert_s3_bucket }}"
object: "{{ ssl_cert_key }}"
dest: "{{ ssl_cert_key_location }}/{{ ssl_cert_key }}"
aws_access_key: "{{ LTS_ACCESS_KEY }}"
aws_secret_key: "{{ LTS_SECRET_KEY }}"
vars:
ansible_python_interpreter: /usr/bin/python3
when: ssl_cert_s3_bucket | length > 0 and ssl_cert_key | length > 0
- name: Change key file permissions
ansible.builtin.file:
path: "{{ ssl_cert_key_location }}/{{ ssl_cert_key }}"
owner: root
group: root
mode: '0400'
when: ssl_cert_s3_bucket | length > 0 and ssl_cert_key | length > 0
- name: Update SSL in Apache config
ansible.builtin.replace:
path: "{{ ssl_apache_config }}"
regexp: "{{ item.regexp }}"
replace: "\\1 {{ item.location }}/{{ item.value }}"
backup: true
when: ssl_apache_config | length > 0 and item.value | length > 0
loop:
- { regexp: "#?(SSLCertificateFile).*$", location: "{{ ssl_cert_file_location }}", value: "{{ ssl_cert_file }}" }
- { regexp: "#?(SSLCertificateChainFile).*$", location: "{{ ssl_cert_file_location }}", value: "{{ ssl_cert_chain_file }}" }
- { regexp: "#?(SSLCertificateKeyFile).*$", location: "{{ ssl_cert_key_location }}", value: "{{ ssl_cert_key }}" }
- name: Restart apache service
ansible.builtin.service:
name: "{{ apache_service }}"
state: restarted
File moved
......@@ -36,11 +36,19 @@ source "openstack" "image" {
build {
sources = ["source.openstack.image"]
provisioner "shell" {
inline = [
"sudo yum install -y libselinux-python3 python3 python3-pip tmux vim git bash-completion curl wget unzip",
"sudo python3 -m pip install --upgrade pip",
"sudo pip3 install s3cmd==2.3.0 ansible==4.10.0 python-openstackclient==5.8.0"
]
}
provisioner "ansible" {
use_proxy = false
user = var.ssh_username
groups = ["compute"]
playbook_file = "./ansible/compute.yml"
playbook_file = "./ansible/login.yml"
roles_path = "./ansible/roles"
extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
......@@ -53,5 +61,8 @@ build {
groups = ["compute"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "./CRI_XCBC/compute-packer.yaml"
extra_arguments = [
"--extra-vars", "${var.extra_vars}"
]
}
}
variable "root_ssh_key" {
type = string
description = "The root key to use for ssh"
default = ""
}
variable "image_name" {
......@@ -87,4 +88,10 @@ variable "volume_size" {
type = number
default = 20
description = "The default volume size for building iamge"
}
\ No newline at end of file
}
variable "extra_vars" {
type = string
default = ""
description = "Extra vars to pass to ansible playbook command"
}
......@@ -40,6 +40,9 @@ build {
use_proxy = false
user = var.ssh_username
groups = ["ood"]
ansible_env_vars = [
"ANSIBLE_CONFIG=./ansible/ansible.cfg"
]
playbook_file = "./ansible/ood.yml"
roles_path = "./ansible/roles"
extra_arguments = [
......@@ -51,7 +54,22 @@ build {
use_proxy = false
user = var.ssh_username
groups = ["ood", "knightly"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
ansible_env_vars = [
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_CONFIG=./CRI_XCBC/ansible.cfg"
]
playbook_file = "./CRI_XCBC/ood-packer.yaml"
extra_arguments = [
"--extra-vars", "${var.extra_vars}"
]
}
provisioner "shell" {
inline = [
"sudo yum install -y libselinux-python3 python3 python3-pip tmux vim git bash-completion curl wget unzip NetworkManager",
"sudo python3 -m pip install --upgrade pip",
"sudo pip3 install s3cmd==2.3.0 ansible==4.10.0 python-openstackclient==5.8.0"
]
}
}
variable "root_ssh_key" {
type = string
default = ""
description = "The root key to use for ssh"
}
......@@ -87,4 +88,10 @@ variable "volume_size" {
type = number
default = 20
description = "The default volume size for building iamge"
}
\ No newline at end of file
}
variable "extra_vars" {
type = string
default = ""
description = "Extra vars to pass to ansible playbook command"
}
......@@ -38,10 +38,9 @@ build {
provisioner "shell" {
inline = [
"sudo sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*",
"sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*",
"sudo yum install -y epel-release",
"sudo yum install -y libselinux-python3 python3 tmux vim git bash-completion curl wget unzip",
"sudo dnf config-manager --set-enabled crb",
"sudo yum install -y libselinux-python3 python3 python3-pip tmux vim git bash-completion curl wget unzip httpd",
"sudo python3 -m pip install --upgrade pip",
"sudo pip3 install s3cmd==2.3.0 ansible==4.10.0 python-openstackclient==5.8.0"
]
......@@ -59,5 +58,8 @@ build {
"ANSIBLE_FORCE_COLOR=true"
]
playbook_file = "./CRI_XCBC/proxy.yaml"
extra_arguments = [
"--extra-vars", "${var.extra_vars}"
]
}
}