Skip to content

Instantly share code, notes, and snippets.

@tlehman
Created November 30, 2023 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlehman/2693c0f632515e17bf32333a889b6da6 to your computer and use it in GitHub Desktop.
Save tlehman/2693c0f632515e17bf32333a889b6da6 to your computer and use it in GitHub Desktop.
blog catalog
node 'your-blog-name' {
# Ensure the required packages are installed
package { ['nginx', 'ruby', 'rails']:
ensure => installed,
}
# Configure Nginx to listen on port 80 and proxy to port 3000
file { '/etc/nginx/sites-available/default':
ensure => file,
content => template('modulename/nginx.conf.erb'),
require => Package['nginx'],
notify => Service['nginx'],
}
# Ensure Nginx service is running and enabled
service { 'nginx':
ensure => running,
enable => true,
}
# Define a systemd service for the Rails app
file { '/etc/systemd/system/railsapp.service':
ensure => file,
content => template('modulename/railsapp.service.erb'),
notify => Service['railsapp'],
}
# Ensure the Rails app service is running and enabled
service { 'railsapp':
ensure => running,
enable => true,
require => File['/etc/systemd/system/railsapp.service'],
}
# Fetch and add SSH public keys from GitHub
exec { 'fetch_ssh_keys':
command => "curl https://github.com/tlehman.keys >> /home/your_user/.ssh/authorized_keys",
path => ['/bin', '/usr/bin'],
unless => "grep -Fq 'tlehman' /home/your_user/.ssh/authorized_keys",
require => Package['curl'],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment