Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppet support #421

Open
seqizz opened this issue Oct 23, 2024 · 0 comments
Open

Puppet support #421

seqizz opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request P2 Not a priority. PRs welcome

Comments

@seqizz
Copy link

seqizz commented Oct 23, 2024

Language: Puppet

Tried to represent most of the language here, also with possible SymbolKind's:

# Resource declaration
# SymbolKind: Object (19)
file { '/etc/ssh/sshd_config':
  ensure => file,
  owner  => 'root',
  group  => 'root',
  mode   => '0600',
}

# Variable assignment
# SymbolKind: Variable (13)
$package_name = 'httpd'

# Conditional statement
# SymbolKind: Function (12)
if $facts['os']['family'] == 'RedHat' {
  $apache = 'httpd'
} else {
  $apache = 'apache2'
}

# Case statement
# SymbolKind: Function (12)
case $facts['os']['name'] {
  'RedHat', 'CentOS': { $ssh_service = 'sshd' }
  'Debian', 'Ubuntu': { $ssh_service = 'ssh' }
  default: { fail('Unsupported operating system') }
}

# Resource defaults
# SymbolKind: Object (19)
File {
  owner => 'root',
  group => 'root',
  mode  => '0644',
}

# Class definition
# SymbolKind: Class (5)
class ssh_server {
  package { 'openssh-server':
    ensure => installed,
  }
  
  service { 'sshd':
    ensure => running,
    enable => true,
  }
}

# Defined resource type
# SymbolKind: Method (6)
define virtual_host($port, $document_root) {
  file { "/etc/apache2/sites-available/${name}.conf":
    ensure  => file,
    content => template('apache/vhost.erb'),
  }
}

# Function
# SymbolKind: Function (12)
$timestamp = generate('/bin/date', '+%Y-%m-%d %H:%M:%S')

# Lambda
# SymbolKind: Function (12)
$userlist = ['alice', 'bob', 'carol']
$users_with_home = $userlist.map |$user| {
  "/home/${user}"
}

# Node definition
# SymbolKind: Class (5)
node 'webserver.example.com' {
  include ssh_server
  include apache
}

Thanks!

@seqizz seqizz added the enhancement New feature or request label Oct 23, 2024
@stevearc stevearc added the P2 Not a priority. PRs welcome label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 Not a priority. PRs welcome
Projects
None yet
Development

No branches or pull requests

2 participants