Skip to content

Instantly share code, notes, and snippets.

@jhoblitt
jhoblitt / comcam-network.md
Last active October 8, 2019 17:57
comcam network migration plan

migration steps

  • update /etc/resolv.conf management for comcam cluster
  • copy foreman hostgroup(s) from comcam-fp01 to production foreman instance
  • remove 10/8 addresses from /etc/hosts on stargate & comcam hosts
  • ensure that all comcam hosts + BMCs are configured for DHCP
  • audit network scripts for extra static configuration. E.g. default gateways, rules, etc.
  • audit iptable rules (expected to be disabled)
  • disable puppetmaster on comcam-fp01; disable puppet agent on all other nodes (to prevent cached catalogs from being re-applied)
@jhoblitt
jhoblitt / database.yml
Last active September 10, 2019 22:35
/etc/foreman/* & /etc/foreman/plugins/foreman-tasks.yaml
### File managed with puppet ###
## Module: 'foreman'
# Database is managed by foreman::database::postgresql
production:
adapter: postgresql
database: foreman
username: foreman
password: "XXX"
pool: 5

puppet master

  • generate new ssh key pair to use as github deploy keys; install per site/pm deploy key on lsst-it/lsst-puppet-hiera-private repo
  • stop local agent (service)
  • cp in sshkey for hiera
  • check /etc/hosts to see if puppet-master is resolvable
  • remove enc configuration from puppet.conf
  • change env to IT_1141_hiera_redux
  • rm old code/hiera paths (due to dir path changes)
@jhoblitt
jhoblitt / eups_manifest.sh
Created July 9, 2019 23:43
download eups manifest file and strip it down to just the package name and git sha1
strip_manifest() {
local manifest_id=${1?manifest id is required}
local base_url='https://raw.githubusercontent.com/lsst/versiondb/master/manifests'
curl -sSL "${base_url}/${manifest_id}.txt" \
| awk '{ print $1 " " $2 }' \
| sort > "${manifest_id}-sha1.txt"
}
@jhoblitt
jhoblitt / Dockerfile
Created April 30, 2019 18:04
Example of adding `rh-git29` scl to an LSST scipipe docker image
ARG BASE_IMAGE=lsstsqre/centos:7-stack-lsst_distrib-w_2019_17
FROM $BASE_IMAGE
USER root
RUN yum install -y rh-git29
RUN echo -e '#!/bin/bash\nsource scl_source enable rh-git29\n' > /etc/profile.d/rh-git29.sh
RUN chmod 0555 /etc/profile.d/rh-git29.sh
USER lsst
@jhoblitt
jhoblitt / aws_c4_to_c5_upgrade.txt
Last active November 16, 2018 01:23
Upgrading aws ec2 instances from c4.* -> c5.*; converting from vif -> ena network driver
instance_id=<foo>
aws ec2 stop-instances --instance-ids $instance_id
#aws ec2 modify-instance-attribute --instance-id $instance_id --instance-type c4.xlarge
aws ec2 modify-instance-attribute --instance-id $instance_id --instance-type c5.xlarge
aws ec2 modify-instance-attribute --instance-id $instance_id --ena-support
aws ec2 start-instances --instance-ids $instance_id
aws ec2 describe-instances --filters "Name=tag:env_name,Values=jenkins-prod" --query 'Reservations[*].Instances[*].InstanceId,ImageId,Tags[?Key==`Name`].Value]'
#!/bin/bash
#set -e
set -o xtrace
for m in {4..10}; do
mon=$(printf "%02d" $m)
for d in {2..30}; do
day=$(printf "%02d" $d)
aws s3 rm --recursive "s3://eups.lsst.codes-backups/2017/${mon}/${day}" &
@jhoblitt
jhoblitt / jenkins-console.groovy
Created November 16, 2017 16:30
Change jenkins job next build number
Jenkins.instance.getItemByFullName("sqre/validate_drp").updateNextBuildNumber(1121)
@jhoblitt
jhoblitt / sed.txt
Last active September 26, 2017 21:45
regex
# https://stackoverflow.com/questions/15965073/return-code-of-sed-for-no-match
# https://unix.stackexchange.com/questions/145402/regex-alternation-or-operator-foobar-in-gnu-or-bsd-sed
# POSIX ERE + GNU
echo " 13.0-10-g692d0a9 d_2017_09_14 " | sed -E '/^\s*([0-9.-]+g(\S+)|([0-9.]+)\+?[0-9]*).+/,${s//\2\3/;b};$Q1')
# pure POSIX ERE -- does not work on OSX
echo " 13.0-10-g692d0a9 d_2017_09_14 " | sed -E '/^[[:space:]]*[[:digit:].-]{1,}g([[:xdigit:]]{1,})[[:space:]]{1,}.*/!{/^[[:space:]]*([[:digit:]\.]{1,})(+[[:digit:]]{1,}){0,1}[[:space:]]{1,}.*/!b};s//\1/'
# python 2.7 / 3 compat -- can not be done on oneline?
@jhoblitt
jhoblitt / sed.txt
Created September 26, 2017 20:35
sed on osx is broken
jenkins-elcap-1:~ square$ echo "foo" | sed -E '/foo/ { /foo/ b }'
sed: 1: "/foo/ { /foo/ b }": unexpected EOF (pending }'s)
jenkins-elcap-1:~ square$ echo "foo" | sed -E '/foo/ { /foo/ }'
sed: 1: "/foo/ { /foo/ }": command } expects up to 0 address(es), found 1