Last active
August 29, 2015 14:07
-
-
Save shurane/3b7a09a93618f97f41bb to your computer and use it in GitHub Desktop.
How to not differentiate between File and Templates. Also passing in variables to templates, if possible.
This file contains 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
[unix_http_server] | |
file=/tmp/supervisor.sock ; path to your socket file | |
[supervisord] | |
logfile=/var/log/supervisord/supervisord.log ; supervisord log file | |
logfile_maxbytes=50MB ; maximum size of logfile before rotation | |
logfile_backups=10 ; number of backed up logfiles | |
loglevel=info ; info, debug, warn, trace | |
pidfile=/var/run/supervisord.pid ; pidfile location | |
nodaemon=false ; run supervisord as a daemon | |
minfds=1024 ; number of startup file descriptors | |
minprocs=200 ; number of process descriptors | |
user=root ; default user | |
childlogdir=/var/log/supervisord/ ; where child log files will live | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///tmp/supervisor.sock ; use unix:// schem for a unix sockets. | |
[include] | |
files=<%= @celery_dir_dest %>/*.conf |
This file contains 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
class supervisor_1 ( | |
$configfile_src = 'puppet:///modules/supervisor/supervisord.conf', | |
$configfile_dest = '/etc/supervisord.conf' | |
){ | |
file { $configfile_dest: | |
ensure => 'present', | |
content => $configfile_src, # no templates here | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
class celery_1 { | |
# before | |
class {'supervisor_1': configfile_src => 'puppet:///modules/supervisor/supervisord.celery.conf'} | |
} | |
class celery_2 { | |
# after | |
# doesn't work because of | |
# - Duplicate declaration: File[/etc/supervisord.conf] is already declared | |
# I don't want to change the way the supervisor class is structured, if possible. | |
class {'supervisor_1': } | |
file { $configfile_dest: | |
ensure => 'present', | |
template => template('celery/supervisord.celery.conf.erb'), | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
# ======================= | |
class supervisor_2 ( | |
$configfile_src = 'puppet:///modules/supervisor/supervisord.conf', | |
$configfile_dest = '/etc/supervisord.conf' | |
){ | |
file { $configfile_dest: | |
ensure => 'present', | |
source => template($configfile_src), # no puppet URIs allowed | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
# ======================= | |
class supervisor_3 ( | |
$configfile_src = 'supervisor/supervisord.conf.erb', | |
$configfile_dest = '/etc/supervisord.conf' | |
){ | |
file { $configfile_dest: | |
ensure => 'present', | |
source => template($configfile_src) | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
class celery_3 { | |
class {'supervisor_3': configfile_src => 'celery/supervisord.celery.conf.erb'} | |
# what about the @celery_dir_dest variable in the template? | |
} | |
# ======================= | |
class supervisor_4($default_config = true){ | |
$configfile_src = 'supervisor/supervisord.conf.erb' | |
$configfile_dest = '/etc/supervisord.conf' | |
if $default_config == true { | |
file { $configfile_dest: | |
ensure => 'present', | |
source => template($configfile_src) | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
} | |
class celery_4 { | |
$celery_dir_dest = '/opt/newscred/supervisor_celery_scripts' | |
class {'supervisor_4': default_config => false } | |
file { '/etc/supervisord.conf': | |
ensure => 'present', | |
source => template('celery/supervisord.celery.conf.erb') | |
mode => '0644', | |
owner => 'root', | |
group => 'root', | |
} | |
# this works, but it duplicates the file information in 2 different files | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment