From 7d58bfaa3f0270787e77040bc028ac2f519745a9 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Sun, 13 Apr 2014 20:20:49 +0400 Subject: [PATCH] Add standalone nailgun role Contains modifications to specify rabbitmq and cobbler servers to allow nailgun to communicate these servers located on different host IPs. Additional parameters for nailgun settings are now explicitly passed to nailgun::venv class. Previously they were visible only due to implict scoping. blueprint fuel-containerization-of-services Change-Id: I0c43bfb74f306830d8df9fc1f66096309faed369 --- .../puppet/nailgun/examples/nailgun-only.pp | 124 ++++++++++++++++++ deployment/puppet/nailgun/examples/site.pp | 1 + deployment/puppet/nailgun/manifests/init.pp | 16 ++- .../puppet/nailgun/manifests/packages.pp | 2 + deployment/puppet/nailgun/manifests/venv.pp | 21 ++- .../puppet/nailgun/manifests/venv/venv.pp | 2 +- .../nailgun/templates/settings.yaml.erb | 10 +- .../templates/supervisord.conf.nailgun.erb | 70 ++++++++++ 8 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 deployment/puppet/nailgun/examples/nailgun-only.pp create mode 100644 deployment/puppet/nailgun/templates/supervisord.conf.nailgun.erb diff --git a/deployment/puppet/nailgun/examples/nailgun-only.pp b/deployment/puppet/nailgun/examples/nailgun-only.pp new file mode 100644 index 0000000000..13157edeef --- /dev/null +++ b/deployment/puppet/nailgun/examples/nailgun-only.pp @@ -0,0 +1,124 @@ +$fuel_settings = parseyaml($astute_settings_yaml) +$fuel_version = parseyaml($fuel_version_yaml) + +if is_hash($::fuel_version) and $::fuel_version['VERSION'] and $::fuel_version['VERSION']['production'] { + $production = $::fuel_version['VERSION']['production'] +} +else { + $production = 'dev' +} + +if $production != 'dev' { + $env_path = "/usr" + $staticdir = "/usr/share/nailgun/static" +} else { + $env_path = "/opt/nailgun" + $staticdir = "/opt/nailgun/share/nailgun/static" +} + +Class["nailgun::user"] -> +Class["nailgun::packages"] -> +Class["nailgun::venv"] -> +Class["nailgun::supervisor"] + +Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'} + +$centos_repos = +[ + { + "id" => "nailgun", + "name" => "Nailgun", + "url" => "\$tree" + }, +] + +$repo_root = "/var/www/nailgun" +#$pip_repo = "/var/www/nailgun/eggs" +$pip_repo = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8080/eggs/" +$gem_source = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8080/gems/" + +$package = "Nailgun" +$version = "0.1.0" +$astute_version = "0.0.2" +$nailgun_group = "nailgun" +$nailgun_user = "nailgun" +$venv = $env_path + +$pip_index = "--no-index" +$pip_find_links = "-f ${pip_repo}" + +$templatedir = $staticdir + +$rabbitmq_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress'] +$rabbitmq_astute_user = "naily" +$rabbitmq_astute_password = "naily" + +$cobbler_url = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:80/cobbler_api" +$cobbler_user = "cobbler" +$cobbler_password = "cobbler" + +$mco_pskey = "unset" +$mco_vhost = "mcollective" +$mco_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress'] +$mco_user = "mcollective" +$mco_password = "marionette" +$mco_connector = "rabbitmq" + +#deprecated +$puppet_master_hostname = "${::fuel_settings['HOSTNAME']}.${::fuel_settings['DNS_DOMAIN']}" + +class { "nailgun::user": + nailgun_group => $nailgun_group, + nailgun_user => $nailgun_user, +} +class { "nailgun::packages": } +class { "nailgun::venv": + venv => $venv, + venv_opts => "--system-site-packages", + package => $package, + version => $version, + pip_opts => "${pip_index} ${pip_find_links}", + production => $production, + nailgun_user => $nailgun_user, + nailgun_group => $nailgun_group, + + database_name => "nailgun", + database_engine => "postgresql", + database_host => $::fuel_settings['ADMIN_NETWORK']['ipaddress'], + database_port => "5432", + database_user => "nailgun", + database_passwd => "nailgun", + + staticdir => $staticdir, + templatedir => $templatedir, + rabbitmq_host => $rabbitmq_host, + rabbitmq_astute_user => $rabbitmq_astute_user, + rabbitmq_astute_password => $rabbitmq_astute_password, + + admin_network => ipcalc_network_by_address_netmask($::fuel_settings['ADMIN_NETWORK']['ipaddress'], $::fuel_settings['ADMIN_NETWORK']['netmask']), + admin_network_cidr => ipcalc_network_cidr_by_netmask($::fuel_settings['ADMIN_NETWORK']['netmask']), + admin_network_size => ipcalc_network_count_addresses($::fuel_settings['ADMIN_NETWORK']['ipaddress'], $::fuel_settings['ADMIN_NETWORK']['netmask']), + admin_network_first => $::fuel_settings['ADMIN_NETWORK']['static_pool_start'], + admin_network_last => $::fuel_settings['ADMIN_NETWORK']['static_pool_end'], + admin_network_netmask => $::fuel_settings['ADMIN_NETWORK']['netmask'], + admin_network_ip => $::fuel_settings['ADMIN_NETWORK']['ipaddress'], + + cobbler_url => $cobbler_url, + cobbler_user => $cobbler_user, + cobbler_password => $cobbler_password, + + mco_pskey => $mco_pskey, + mco_vhost => $mco_vhost, + mco_host => $mco_host, + mco_user => $mco_user, + mco_password => $mco_password, + mco_connector => $mco_connector, + + puppet_master_hostname => $puppet_master_hostname, +} +class { "nailgun::supervisor": + nailgun_env => $env_path, + ostf_env => $env_path, + conf_file => "nailgun/supervisord.conf.nailgun.erb", +} + diff --git a/deployment/puppet/nailgun/examples/site.pp b/deployment/puppet/nailgun/examples/site.pp index cbde35bb9e..2631faa5a3 100644 --- a/deployment/puppet/nailgun/examples/site.pp +++ b/deployment/puppet/nailgun/examples/site.pp @@ -43,6 +43,7 @@ node default { $mco_password = "marionette" $mco_connector = "rabbitmq" + $rabbitmq_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress'] $rabbitmq_astute_user = "naily" $rabbitmq_astute_password = "naily" diff --git a/deployment/puppet/nailgun/manifests/init.pp b/deployment/puppet/nailgun/manifests/init.pp index 18386ec77c..7504772040 100644 --- a/deployment/puppet/nailgun/manifests/init.pp +++ b/deployment/puppet/nailgun/manifests/init.pp @@ -22,7 +22,6 @@ class nailgun( $templatedir, $logdumpdir = "/var/www/nailgun/dump", - $cobbler_url = "http://localhost/cobbler_api", $cobbler_user = "cobbler", $cobbler_password = "cobbler", $cobbler_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress'], @@ -131,6 +130,7 @@ class nailgun( staticdir => $staticdir, templatedir => $templatedir, + rabbitmq_host => $rabbitmq_host, rabbitmq_astute_user => $rabbitmq_astute_user, rabbitmq_astute_password => $rabbitmq_astute_password, @@ -140,8 +140,20 @@ class nailgun( admin_network_first => $::fuel_settings['ADMIN_NETWORK']['static_pool_start'], admin_network_last => $::fuel_settings['ADMIN_NETWORK']['static_pool_end'], admin_network_netmask => $::fuel_settings['ADMIN_NETWORK']['netmask'], - admin_network_ip => $::fuel_settings['ADMIN_NETWORK']['ipaddress'] + admin_network_ip => $::fuel_settings['ADMIN_NETWORK']['ipaddress'], + cobbler_url => $cobbler_url, + cobbler_user => $cobbler_user, + cobbler_password => $cobbler_password, + + mco_pskey => $mco_pskey, + mco_vhost => $mco_vhost, + mco_host => $mco_host, + mco_user => $mco_user, + mco_password => $mco_password, + mco_connector => $mco_connector, + + puppet_master_hostname => $puppet_master_hostname, } class {"nailgun::astute": diff --git a/deployment/puppet/nailgun/manifests/packages.pp b/deployment/puppet/nailgun/manifests/packages.pp index e70b18fa91..639b7f06be 100644 --- a/deployment/puppet/nailgun/manifests/packages.pp +++ b/deployment/puppet/nailgun/manifests/packages.pp @@ -10,6 +10,8 @@ class nailgun::packages( nailgun_safe_package { "supervisor": } nailgun_safe_package { "nginx": } + nailgun_safe_package { "crontabs": } + nailgun_safe_package { "cronie-anacron": } if ( $production == 'dev' ) { nailgun_safe_package { "python-virtualenv": } diff --git a/deployment/puppet/nailgun/manifests/venv.pp b/deployment/puppet/nailgun/manifests/venv.pp index cd3693b3e8..7933811630 100644 --- a/deployment/puppet/nailgun/manifests/venv.pp +++ b/deployment/puppet/nailgun/manifests/venv.pp @@ -19,6 +19,7 @@ class nailgun::venv( $staticdir, $templatedir, + $rabbitmq_host, $rabbitmq_astute_user, $rabbitmq_astute_password, @@ -30,12 +31,25 @@ class nailgun::venv( $admin_network_netmask, $admin_network_ip, + $cobbler_url, + $cobbler_user = "cobbler", + $cobbler_password = "cobbler", + + $mco_pskey, + $mco_vhost, + $mco_host, + $mco_user, + $mco_password, + $mco_connector, + + $puppet_master_hostname, + $exclude_network = $admin_network, $exclude_cidr = $admin_network_cidr, ) { - if $production == 'prod' { + if $production != 'dev' { package{'nailgun':} } else { nailgun::venv::venv { $venv: @@ -134,12 +148,13 @@ class nailgun::venv( } } - + package {'cronie-anacron': } file {"/etc/cron.daily/capacity": content => template("nailgun/cron_daily_capacity.erb"), owner => 'root', group => 'root', - mode => 0644 + mode => '0644', + require => Package['cronie-anacron'] } } diff --git a/deployment/puppet/nailgun/manifests/venv/venv.pp b/deployment/puppet/nailgun/manifests/venv/venv.pp index 6e556f079b..9fff8a5b48 100644 --- a/deployment/puppet/nailgun/manifests/venv/venv.pp +++ b/deployment/puppet/nailgun/manifests/venv/venv.pp @@ -9,7 +9,7 @@ define nailgun::venv::venv( if $ensure == 'present' { - $root_parent = inline_template("<%= venv.match(%r!(.+)/.+!)[1] %>") + $root_parent = inline_template("<%= @venv.match(%r!(.+)/.+!)[1] %>") if !defined(File[$root_parent]) { file { $root_parent: diff --git a/deployment/puppet/nailgun/templates/settings.yaml.erb b/deployment/puppet/nailgun/templates/settings.yaml.erb index 70716ff464..1ce1233c97 100644 --- a/deployment/puppet/nailgun/templates/settings.yaml.erb +++ b/deployment/puppet/nailgun/templates/settings.yaml.erb @@ -1,4 +1,4 @@ -LISTEN_ADDRESS: "127.0.0.1" +LISTEN_ADDRESS: "0.0.0.0" LISTEN_PORT: "8001" DEVELOPMENT: false @@ -37,7 +37,7 @@ VLANS_RANGE_END: "1000" RABBITMQ: fake: "0" - hostname: "127.0.0.1" + hostname: "<%= @rabbitmq_host %>" port: 5672 userid: "<%= @rabbitmq_astute_user %>" password: "<%= @rabbitmq_astute_password %>" @@ -51,14 +51,14 @@ PATH_TO_BOOTSTRAP_SSH_KEY: "/root/.ssh/bootstrap.rsa" MASTER_IP: "<%= @admin_network_ip %>" -COBBLER_URL: "<%= scope.lookupvar('nailgun::cobbler_url') %>" +COBBLER_URL: "<%= @cobbler_url %>" COBBLER_USER: "<%= @cobbler_user %>" COBBLER_PASSWORD: "<%= @cobbler_password %>" COBBLER_PROFILE: "centos-x86_64" MCO_PSKEY: "<%= @mco_pskey %>" MCO_VHOST: "<%= @mco_vhost %>" -MCO_HOST: <%= scope.lookupvar('nailgun::mco_host') %> +MCO_HOST: <%= @mco_host %> MCO_USER: "<%= @mco_user %>" MCO_PASSWORD: "<%= @mco_password %>" MCO_CONNECTOR: "<%= @mco_connector %>" @@ -67,5 +67,5 @@ PUPPET_MASTER_HOST: "<%= @puppet_master_hostname %>" PUPPET_VERSION: "2.7.19" DNS_DOMAIN: "<%= @domain %>" -DNS_SERVERS: "<%= scope.lookupvar('nailgun::puppet_master_ip') %>" +DNS_SERVERS: "<%= @cobbler_url %>" DNS_SEARCH: "<%= @domain %>" diff --git a/deployment/puppet/nailgun/templates/supervisord.conf.nailgun.erb b/deployment/puppet/nailgun/templates/supervisord.conf.nailgun.erb new file mode 100644 index 0000000000..ed4080ff4b --- /dev/null +++ b/deployment/puppet/nailgun/templates/supervisord.conf.nailgun.erb @@ -0,0 +1,70 @@ +[rpcinterface:supervisor] +; required for supervisorctl +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[unix_http_server] +file=/var/run/supervisor.sock + +[supervisord] +logfile=/var/log/supervisor/supervisord.log +loglevel=debug +pidfile=/var/run/supervisord.pid +childlogdir=/var/log/supervisor + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock + +[program:nailgun] +command=/usr/bin/nailgund +process_name=%(program_name)s +numprocs=1 +numprocs_start=0 +autostart=true +autorestart=true +startsecs=10 +startretries=1000000 +exitcodes=0,2 +stopsignal=INT +stopwaitsecs=60 +redirect_stderr=true +stdout_logfile=/var/log/nailgun/app.log +stdout_capture_maxbytes=0 +stdout_events_enabled=false +serverurl=AUTO + +[program:assassind] +command=/usr/bin/assassind +process_name=%(program_name)s +numprocs=1 +numprocs_start=0 +autostart=true +autorestart=true +startsecs=10 +startretries=1000000 +exitcodes=0 +stopsignal=INT +stopwaitsecs=60 +redirect_stderr=true +stdout_logfile=/var/log/nailgun/assassind.log +stdout_capture_maxbytes=0 +stdout_events_enabled=false +serverurl=AUTO + +[program:receiverd] +command=/usr/bin/receiverd +process_name=%(program_name)s +numprocs=1 +numprocs_start=0 +autostart=true +autorestart=true +startsecs=10 +startretries=1000000 +exitcodes=0 +stopsignal=INT +stopwaitsecs=60 +redirect_stderr=true +stdout_logfile=/var/log/nailgun/receiverd.log +stdout_capture_maxbytes=0 +stdout_events_enabled=false +serverurl=AUTO +