Skip to content

Install Visual Studio Code

step1: enable Microsoft repo and refresh package list

guru1@vm1:-$ _
1
2
3
4
5
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt-get update

step2: install the package

guru1@vm1:-$ _
sudo apt-get install code

step3: only 'root' can write in the "manifest and modules" directories

guru1@vm1:-$ _
sudo apt-get install tree
tree -ugp /etc/puppetlabs/code/environments/production/
/etc/puppetlabs/code/environments/production/
1
2
3
4
5
6
7
├── [drwxr-xr-x root     root    ]  data
├── [-rw-r--r-- root     root    ]  environment.conf
├── [-rw-r--r-- root     root    ]  hiera.yaml
├── [drwxr-xr-x root     root    ]  manifests
└── [drwxr-xr-x root     root    ]  modules

3 directories, 2 files

step4: quick fix

guru1@vm1:-$ _
sudo chmod o+w /etc/puppetlabs/code/environments/production/{manifests,modules}

step5: open Visual Studio Code in the production directory

guru1@vm1:-$ _
cd /etc/puppetlabs/code/environments/production/
code .

step6: configure Visual Studio Code

  • Trust the author of all files...
  • Close the "Get Started" tab
  • Create site.pp + Search marketplace
  • Select "Puppet: the Official Puppet VSCode extension
  • Click "Install"
  • Click "Don't show again"
  • Close the "Extension: Puppet" tab

step7: writing your first main manifest

  • Don't forget to File -> Save (All)

Main manifest

step8: run puppet manually (apply catalog)

guru2@vm2:-$ _
sudo puppet agent --server=vm1.opensysadmins.lab --no-daemonize --verbose --onetime
Back to top