Created
May 16, 2020 16:21
-
-
Save svpernova09/47a9be47df21c2d0a56584adb39c8a05 to your computer and use it in GitHub Desktop.
Ruby Array / Hash Logic to enable / disable Ubuntu Services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Snippet | |
# Enable Services | |
if settings.has_key?('services') | |
settings['services'].each do |service| | |
if service.include?('enabled') | |
enable = service['enabled'] | |
enable.each do |enable_service| | |
config.vm.provision "shell", inline: "sudo systemctl enable #{enable_service}" | |
end | |
end | |
if service.include?('disabled') | |
disable = service['disabled'] | |
disable.each do |disable_service| | |
config.vm.provision "shell", inline: "sudo systemctl disable #{disable_service}" | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
#snippet | |
services: | |
- enabled: | |
- "postgresql@12-main" | |
- "postgresql@11-main" | |
- disabled: | |
- "postgresql@10-main" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment