Added support for Linux Mint

This commit is contained in:
Gene Liverman 2017-09-18 19:01:57 -07:00 committed by Gene Liverman
parent e23ea50d4b
commit b0ec3a08ba
23 changed files with 337 additions and 87 deletions

View file

@ -0,0 +1,19 @@
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|
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

@ -1,13 +1,5 @@
# the base profile should include component modules that will be on all nodes
class profile::base {
$pip_packages = [
'psutil',
'powerline-status',
]
package { $pip_packages:
ensure => 'latest',
provider => 'pip',
require => Package['python'],
}
}

View file

@ -0,0 +1,20 @@
# Select a profile based on the OS family
class profile::linux {
case $facts['os']['family'] {
'Debian': { include ::profile::linux::debian }
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

@ -71,6 +71,18 @@ class profile::mac {
provider => 'brewcask',
}
$pip_packages = [
'psutil',
'powerline-status',
]
package { $pip_packages:
ensure => 'latest',
provider => 'pip',
require => Package['python'],
}
file { "${homedir}/repos":
ensure => 'directory',
}

View file

@ -6,6 +6,9 @@ class role::workstation {
'Darwin': {
include ::profile::mac
}
'Linux': {
include ::profile::linux
}
default: {
fail("${facts['kernel']} hasn't been setup in the workstation role yet.")
}