Update repo structure as part of nixification

This commit is contained in:
Gene Liverman 2023-09-14 00:01:31 -04:00
parent 49e67c64fb
commit cc0efcfdde
56 changed files with 181 additions and 154 deletions

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
forge 'http://forge.puppetlabs.com'
# The next line translates to '../../vendor/puppet_modules' aka ~/.dotfiles/vendor/puppet_modules
moduledir "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/vendor/puppet_modules"
mod 'puppetlabs-apt', '7.3.0'
mod 'puppetlabs-stdlib', '4.25.1'
mod 'puppetlabs-vcsrepo', '3.1.0'
mod 'thekevjames-homebrew', '1.8.3'

View file

@ -0,0 +1,2 @@
modulepath = modules:site:~/.dotfiles/vendor/puppet_modules:$basemodulepath
config_version = 'scripts/config_version.sh $environmentpath'

View file

@ -0,0 +1,11 @@
---
version: 5
defaults: # Used for any hierarchy level that omits these keys.
datadir : hieradata # This path is relative to hiera.yaml's directory.
data_hash : yaml_data # Use the built-in YAML backend.
hierarchy:
- name: "Per-node data"
path: "nodes/%{hostname}.yaml"
- name: "Common data"
path: "common.yaml"

View file

@ -0,0 +1,2 @@
---
foo: bar

View file

@ -0,0 +1,2 @@
---
homedir: '/Users/gene'

View file

@ -0,0 +1,2 @@
---
homedir: '/home/gene'

View file

@ -0,0 +1,2 @@
---
homedir: '/Users/gene.liverman'

View file

@ -0,0 +1,2 @@
---
homedir: '/home/gene'

View file

@ -0,0 +1,29 @@
## site.pp ##
# DEFAULT NODE
# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the via an ENC for that node.
node default {
notify{'This is from the default node.':}
}
node 'bowl' {
include role::workstation
}
node 'gene' {
include role::workstation
}
node 'mintstring' {
include role::workstation
}
node 'yellowbadger' {
include role::workstation
}

View file

@ -0,0 +1,25 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
begin
require 'rugged'
rescue LoadError
t = Time.new
puts t.to_i
else
environmentpath = ARGV[0]
environment = ARGV[1]
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
head = repo.head
# sha1 hash of the newest commit
head_sha = head.target_id
# the commit message associated the newest commit
# commit = repo.lookup(head_sha)
# add something to find the remote url
puts head_sha
end

View file

@ -0,0 +1,5 @@
#!/bin/bash
/usr/bin/git --version > /dev/null 2>&1 &&
/usr/bin/git --git-dir $1/../.git rev-parse HEAD ||
date +%s

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
Facter.add(:os_release) do
confine kernel: 'Linux'
setcode do
file_path = '/etc/os-release'
if File.exist?(file_path)
os_release_hash = {}
File.open(file_path, 'r') do |file|
file.each_line do |line|
next if line.nil? || line.strip.length.eql?(0)
line_data = line.split('=')
key = line_data[0].downcase
value = line_data[1].strip.gsub(/(^")|("$)/, '')
os_release_hash[key] = value
end
end
os_release_hash
end
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:find_group) do
dispatch :find_group do
param 'String', :some_path
return_type 'String'
end
def find_group(some_path)
File.stat(some_path).gid.to_s
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:find_owner) do
dispatch :find_owner do
param 'String', :some_path
return_type 'String'
end
def find_owner(some_path)
File.stat(some_path).uid.to_s
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:homedir_to_user) do
dispatch :homedir_to_user do
param 'String', :some_path
return_type 'String'
end
def homedir_to_user(some_path)
some_path.split('/')[-1]
end
end

View file

@ -0,0 +1,5 @@
# the base profile should include component modules that will be on all nodes
class profile::base {
}

View file

@ -0,0 +1,21 @@
# Select a profile based on the OS family
class profile::linux {
case $facts['os']['family'] {
'Debian': { include profile::linux::debian }
'RedHat': { include profile::linux::el }
default: { fail("${facts['os']['family']} isn't supported yet") }
}
exec { 'download hub':
path => '/bin:/usr/bin',
command => "curl -s https://api.github.com/repos/github/hub/releases/latest | grep \"browser_download_url.*linux-amd64\" | cut -d '\"' -f4 | xargs -n 1 curl -L | tar -xzvf - -C /tmp && mv /tmp/hub* /usr/local/hub",
creates => '/usr/local/hub',
}
file {'/usr/local/bin/hub':
ensure => 'link',
target => '/usr/local/hub/bin/hub',
}
}

View file

@ -0,0 +1,135 @@
# Profile for the Debian family of OS's
class profile::linux::debian {
$homedir = lookup('homedir')
$uid = find_owner($homedir)
$gid = find_group($homedir)
File {
owner => $uid,
group => $gid,
}
Vcsrepo {
user => $uid,
owner => $uid,
group => $gid,
}
if $facts['os_release']['ubuntu_codename'] {
$release = $facts['os_release']['ubuntu_codename']
}
elsif $facts['os']['lsb']['distcodename'] {
$release = $facts['os']['lsb']['distcodename']
}
else {
fail("Can't determine what to use in 'release' for the Docker repo")
}
apt::source { 'docker':
location => 'https://download.docker.com/linux/ubuntu',
release => $release,
repos => 'stable',
key => {
'id' => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
'source' => 'https://download.docker.com/linux/ubuntu/gpg',
},
}
$apt_packages = [
'apt-transport-https',
'bash-completion',
'ca-certificates',
'cmake',
'coreutils',
'curl',
'figlet',
'git',
'git-flow',
'pinentry-gnome3',
'powerline',
'python',
'python-pip',
'python-psutil',
'scdaemon',
'software-properties-common',
'tmux',
'tree',
'yubikey-personalization-gui',
'zsh',
]
package { $apt_packages:
ensure => 'installed',
require => Apt::Source['docker'],
}
exec { 'set-shell-to-zsh':
path => '/bin:/usr/bin',
command => "chsh -s /usr/bin/zsh `grep '${uid}:${gid}' /etc/passwd |cut -d ':' -f1`",
cwd => $homedir,
logoutput => true,
environment => "HOME=${homedir}",
unless => "grep '${uid}:${gid}' /etc/passwd | grep '/usr/bin/zsh'",
}
$dirs = [
"${homedir}/.local",
"${homedir}/.local/share",
"${homedir}/.local/share/fonts",
"${homedir}/.vim",
"${homedir}/.vim/bundle",
"${homedir}/repos",
]
file { $dirs:
ensure => 'directory',
}
vcsrepo { "${homedir}/.oh-my-zsh":
ensure => 'present',
provider => 'git',
source => 'https://github.com/robbyrussell/oh-my-zsh.git',
}
vcsrepo { "${homedir}/.oh-my-zsh/custom/themes":
ensure => 'latest',
provider => 'git',
source => 'git@github.com:genebean/my-oh-zsh-themes.git',
}
vcsrepo { "${homedir}/.vim/bundle/Vundle.vim":
ensure => 'latest',
provider => 'git',
source => 'https://github.com/VundleVim/Vundle.vim.git',
require => File[$dirs],
}
vcsrepo { "${homedir}/repos/powerline-fonts":
ensure => 'latest',
provider => 'git',
source => 'https://github.com/powerline/fonts.git',
require => File[$dirs],
notify => Exec['update-fonts'],
}
exec { 'update-fonts':
command => "${homedir}/repos/powerline-fonts/install.sh",
cwd => "${homedir}/repos/powerline-fonts",
logoutput => true,
environment => "HOME=${homedir}",
refreshonly => true,
notify => Exec['set-font-ownership'],
}
exec { 'set-font-ownership':
path => '/bin:/usr/bin',
command => "chown -R ${uid}:${gid} ${homedir}/.local/share/fonts/*",
cwd => $homedir,
logoutput => true,
environment => "HOME=${homedir}",
require => Exec['update-fonts'],
refreshonly => true,
}
}

View file

@ -0,0 +1,126 @@
# Profile for the Red Hat family of OS's
class profile::linux::el {
$homedir = lookup('homedir')
$uid = find_owner($homedir)
$gid = find_group($homedir)
$user = homedir_to_user($homedir)
include profile::linux::el::docker_repos
Yumrepo <| |> -> Package <| |> # lint:ignore:spaceship_operator_without_tag
$yum_packages = [
'cmake',
'device-mapper-persistent-data',
'docker-ce',
'figlet',
'git',
'gitflow',
'lvm2',
'python2-pip',
'python2-psutil',
'tmux',
'tree',
'yum-utils',
'zsh',
]
$python_pacakges = [
'powerline-status',
]
package {
default:
ensure => 'installed',
;
'epel-release':
notify => Exec['yum clean all'],
;
$yum_packages:
require => Package['epel-release'],
;
$python_pacakges:
ensure => 'latest',
provider => 'pip',
require => Package['python2-pip'],
;
}
$dirs = [
"${homedir}/.local",
"${homedir}/.local/share",
"${homedir}/.local/share/fonts",
"${homedir}/.vim",
"${homedir}/.vim/bundle",
"${homedir}/repos",
]
file { $dirs:
ensure => 'directory',
owner => $uid,
group => $gid,
}
# Unlike on Mint, powerline is pulled from pip.
# This makes it so that the line in .tmux.conf works on both.
file { '/usr/share/powerline':
ensure => 'link',
target => '/usr/lib/python2.7/site-packages/powerline',
require => Package[$python_pacakges],
}
vcsrepo {
default:
ensure => 'latest',
user => $user,
owner => $uid,
group => $gid,
provider => 'git',
;
"${homedir}/.oh-my-zsh":
ensure => 'present',
source => 'https://github.com/robbyrussell/oh-my-zsh.git',
;
"${homedir}/.oh-my-zsh/custom/themes":
source => 'git@github.com:genebean/my-oh-zsh-themes.git',
;
"${homedir}/.vim/bundle/Vundle.vim":
source => 'https://github.com/VundleVim/Vundle.vim.git',
require => File[$dirs],
;
"${homedir}/repos/powerline-fonts":
source => 'https://github.com/powerline/fonts.git',
require => File[$dirs],
notify => Exec['update-fonts'],
;
}
exec {
default:
logoutput => true,
environment => "HOME=${homedir}",
refreshonly => true,
;
'yum clean all':
command => '/bin/yum clean all',
;
'set-shell-to-zsh':
path => '/bin:/usr/bin',
command => "chsh -s /usr/bin/zsh `grep '${uid}:${gid}' /etc/passwd |cut -d ':' -f1`",
cwd => $homedir,
unless => "grep '${uid}:${gid}' /etc/passwd | grep '/usr/bin/zsh'",
require => Package['zsh'],
;
'update-fonts':
command => "${homedir}/repos/powerline-fonts/install.sh",
cwd => "${homedir}/repos/powerline-fonts",
notify => Exec['set-font-ownership'],
;
'set-font-ownership':
path => '/bin:/usr/bin',
command => "chown -R ${uid}:${gid} ${homedir}/.local/share/fonts/*",
cwd => $homedir,
require => Exec['update-fonts'],
;
}
}

View file

@ -0,0 +1,101 @@
# These repos are the ones setup by
# https://download.docker.com/linux/centos/docker-ce.repo
class profile::linux::el::docker_repos {
yumrepo { 'docker-ce-edge':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/$basearch/edge',
descr => 'Docker CE Edge - $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-edge-debuginfo':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/debug-$basearch/edge',
descr => 'Docker CE Edge - Debuginfo $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-edge-source':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/source/edge',
descr => 'Docker CE Edge - Sources',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-nightly':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/$basearch/nightly',
descr => 'Docker CE Nightly - $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-nightly-debuginfo':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/debug-$basearch/nightly',
descr => 'Docker CE Nightly - Debuginfo $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-nightly-source':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/source/nightly',
descr => 'Docker CE Nightly - Sources',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-stable':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/$basearch/stable',
descr => 'Docker CE Stable - $basearch',
enabled => '1',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-stable-debuginfo':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/debug-$basearch/stable',
descr => 'Docker CE Stable - Debuginfo $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-stable-source':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/source/stable',
descr => 'Docker CE Stable - Sources',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-test':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/$basearch/test',
descr => 'Docker CE Test - $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-test-debuginfo':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/debug-$basearch/test',
descr => 'Docker CE Test - Debuginfo $basearch',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
yumrepo { 'docker-ce-test-source':
ensure => 'present',
baseurl => 'https://download.docker.com/linux/centos/7/source/test',
descr => 'Docker CE Test - Sources',
enabled => '0',
gpgcheck => '1',
gpgkey => 'https://download.docker.com/linux/centos/gpg',
}
}

View file

@ -0,0 +1,128 @@
# this contains the mac specific stuff
class profile::mac {
# $path = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin'
# notify{'This is from the mac profile.':}
# exec { 'install homebrew':
# command => '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"',
# path => $path,
# creates => '/usr/local/bin/brew',
# }
$homedir = lookup('homedir')
#Package { provider => 'homebrew' }
$homebrew_packages = [
'bash-completion',
'bundler-completion',
'cmake',
'coreutils',
'csshx',
'docker-completion',
'elixir',
'erlang',
'figlet',
'git',
'git-flow',
'gnu-tar',
'hub',
'iftop',
'jq',
'kompose',
'mutt',
'ncftp',
'openssh',
'packer',
'python',
'ruby',
'sl',
'socat',
'terraform',
'tmux',
'tree',
'unrar',
'vagrant-completion',
'vim',
'watch',
'wget',
'zsh',
'zsh-completions',
]
package { $homebrew_packages:
ensure => 'installed',
provider => 'brew',
}
# $homebrew_casks = [
# '1password',
# 'adium',
# 'android-file-transfer',
# 'android-platform-tools',
# 'araxis-merge',
# 'atom',
# 'caffeine',
# 'docker',
# 'firefox',
# 'fliqlo',
# 'google-chrome',
# 'hipchat',
# 'iterm2',
# 'slack',
# 'sourcetree',
# 'visual-studio-code',
# ]
#
# package { $homebrew_casks:
# ensure => 'installed',
# provider => 'brewcask',
# }
$pip_packages = [
'psutil',
'powerline-status',
]
package { $pip_packages:
ensure => 'latest',
provider => 'pip',
require => Package['python'],
}
file { "${homedir}/repos":
ensure => 'directory',
}
vcsrepo { "${homedir}/.vim/bundle/Vundle.vim":
ensure => 'latest',
provider => 'git',
source => 'https://github.com/VundleVim/Vundle.vim.git',
}
vcsrepo { "${homedir}/repos/powerline-fonts":
ensure => 'latest',
provider => 'git',
source => 'https://github.com/powerline/fonts.git',
require => File["${homedir}/repos"],
notify => Exec['update-fonts'],
}
exec { 'update-fonts':
command => "${homedir}/repos/powerline-fonts/install.sh",
cwd => "${homedir}/repos/powerline-fonts",
logoutput => true,
environment => "HOME=${homedir}",
refreshonly => true,
}
vcsrepo { "${homedir}/.oh-my-zsh":
ensure => 'present',
provider => 'git',
source => 'https://github.com/robbyrussell/oh-my-zsh.git',
}
vcsrepo { "${homedir}/.oh-my-zsh/custom/themes":
ensure => 'latest',
provider => 'git',
source => 'git@github.com:genebean/my-oh-zsh-themes.git',
}
}

View file

@ -0,0 +1,7 @@
# Includes all the profiles needed for a server.
# One big difference between this and the workstation role is that you generally
# are not standing in front of the system and / or there is no graphical
# interface.
class role::server {
include profile::base
}

View file

@ -0,0 +1,16 @@
# Includes all the profiles needed for a workstation
class role::workstation {
include profile::base
case $facts['kernel'] {
'Darwin': {
include profile::mac
}
'Linux': {
include profile::linux
}
default: {
fail("${facts['kernel']} hasn't been setup in the workstation role yet.")
}
} # end of kernel case statement
}