How to set up a custom bash environment for different puppet users?

I'm just starting with a puppet (and a tramp) to set up a development environment for our team, which consists of 8+ developers, each of which has its own specific bash configuration, etc. I have all the software installed on the system to quickly deploy new development virtual machines, but I'm not sure the best way to set up a development environment for each specific user in an automatic way (we will have several development environments, and it will be convenient to write this once and do).

For example, I would like to configure the user joe , clone the Joe configuration configuration from github, and then run the script in this github repository to configure the environment for Joe. Any suggestions on how to do this for Joe, as well as Jimmy, James, Julie, Jane, Jim, Jake and Jimbo?

With his help, the development machines will certainly be ubuntu systems.

+6
source share
2 answers

In addition to the @Matt suggestion, I created a custom puppet module that creates a configuration environment for each user based on their github preferences. The resulting users puppet module looks something like this:

 users/ β”œβ”€β”€ manifests β”‚  β”œβ”€β”€ init.pp # base level configurations for all users β”‚  β”œβ”€β”€ jake.pp # custom setup for jake β”‚  β”œβ”€β”€ james.pp # custom setup for james β”‚  β”œβ”€β”€ jane.pp # custom setup for jane β”‚  β”œβ”€β”€ jim.pp # custom setup for jim β”‚  β”œβ”€β”€ jimbo.pp # custom setup for joe β”‚  β”œβ”€β”€ jimmy.pp # custom setup for jimmy β”‚  β”œβ”€β”€ joe.pp # custom setup for julie β”‚  └── julie.pp # custom setup for jimbo └── templates 

The corresponding tidbit is in the user settings files for each user. For example, here's what jim.pp might look jim.pp :

 class users::jim { # make sure that all base configuration in init.pp is set up first require users # add the user here user { 'jim': # comment => 'Dean Malmgren', home => '/home/jim', shell => '/bin/bash', uid => 201, managehome => 'true', groups => ['sudo', 'vagrant'], provider => 'useradd', password => '$6$kxHLEuHW$78m3zHVLu0XUUDaU4bT.PEg./FfcloJiWml', } # clone the repository the first time exec { 'jim-clone-dotfiles': command => 'git clone git://github.com/jim/dotfiles.git && python dotfiles/create_softlinks.py', cwd => '/home/jim', creates => '/home/jim/dotfiles', user => 'jim', group => 'jim', require => [ Package['git'] ], } # fetch and update if jim decides to update his dotfiles repo exec { 'jim-update-dotfiles': command => 'git merge --ff-only origin/master && python create_softlinks.py', cwd => '/home/jim/dotfiles', unless => 'git fetch && git diff --exit-code origin/master', user => 'jim', group => 'jim', require => Exec['jim-clone-dotfiles'], } } 
+3
source

You can use the puppet fact in the stray file to set the username and pass it on with your puppet manifest. Something like the following:

 Vagrant.configure("2") do |config| config.vm.provision :puppet do |puppet| puppet.facter = { "user_name" => ENV['USER'] } end end 

This will cause the current username to be entered into the puppet, and then in your manifest files you can use the variable "$user_name" in your git commands to verify the repo is correct and perform other related tasks.

+2
source

Source: https://habr.com/ru/post/945765/


All Articles