From e9c1fff9d87508ca1104b3cf53341007d1462ae9 Mon Sep 17 00:00:00 2001 From: Frederic Francois Date: Wed, 3 Jul 2019 14:36:41 +0100 Subject: [PATCH] add puppet node & class for Gatling Add the necessary code to deploy gatling on AWS --- Rakefile | 1 + hieradata_aws/common.yaml | 2 + modules/govuk/manifests/node/s_apt.pp | 1 + modules/govuk/manifests/node/s_gatling.pp | 77 +++++++++++++++++++ .../s_gatling/gatling_cluster_vhost.conf.erb | 12 +++ .../templates/govuk_node_list_aws.erb | 8 +- modules/hosts/manifests/purge.pp | 1 + 7 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 modules/govuk/manifests/node/s_gatling.pp create mode 100644 modules/govuk/templates/node/s_gatling/gatling_cluster_vhost.conf.erb diff --git a/Rakefile b/Rakefile index 1f101cc31b..5e3a0a143c 100644 --- a/Rakefile +++ b/Rakefile @@ -278,6 +278,7 @@ task :check_consistency_between_aws_and_carrenza do govuk::node::s_apt::gemstash_service govuk::node::s_asset_base::alert_hostname govuk::node::s_base::log_remote + govuk::node::s_gatling::apt_mirror_hostname govuk::node::s_postgresql_primary::alert_hostname govuk_bundler::config::service govuk_containers::apps::router::envvars diff --git a/hieradata_aws/common.yaml b/hieradata_aws/common.yaml index 7ce764f773..9bfa3680e1 100644 --- a/hieradata_aws/common.yaml +++ b/hieradata_aws/common.yaml @@ -811,6 +811,8 @@ govuk::node::s_content_data_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mir govuk::node::s_email_alert_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}" +govuk::node::s_gatling::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}" + govuk::node::s_graphite::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}" govuk::node::s_licensify_lb::backend_app_servers: diff --git a/modules/govuk/manifests/node/s_apt.pp b/modules/govuk/manifests/node/s_apt.pp index d6e7b1f271..df6c515301 100644 --- a/modules/govuk/manifests/node/s_apt.pp +++ b/modules/govuk/manifests/node/s_apt.pp @@ -117,6 +117,7 @@ aptly::repo { 'collectd': } aptly::repo { 'elastic-beats': } aptly::repo { 'etcdctl': } + aptly::repo { 'govuk-gatling': } aptly::repo { 'gdal': } aptly::repo { 'gof3r': } aptly::repo { 'google-cloud-sdk-trusty': } diff --git a/modules/govuk/manifests/node/s_gatling.pp b/modules/govuk/manifests/node/s_gatling.pp new file mode 100644 index 0000000000..2b0ea33195 --- /dev/null +++ b/modules/govuk/manifests/node/s_gatling.pp @@ -0,0 +1,77 @@ +# == Class: govuk::node::s_gatling +# +# This machine class is used to run Gatling, a load testing tool. +# +# === Parameters +# +# [*root_dir*] +# The root of the website where Gatling stores its results +# Default = '/home/gatling/gatling-software/results' +# +# [*repo*] +# The github repository where GOV.UK defines its load tests +# Default = 'git@github.com:alphagov/govuk-load-testing.git' +# +# [*commit*] +# The version of the repository where GOV.UK defines its load tests +# Default = 'master' +# +# +# +class govuk::node::s_gatling ( + $root_dir = '/usr/local/bin/gatling/results', + $repo = 'https://github.com/alphagov/govuk-load-testing.git', + $commit = 'master', + $apt_mirror_hostname = undef, +) inherits govuk::node::s_base { + + # User used to run Gatling + govuk_user { 'gatling': + fullname => 'GOV.UK Gatling', + email => 'webops@digital.cabinet-office.gov.uk', + groups => ['admin', 'deploy', 'adm', 'www-data' ], + } + + # repository where GOV.UK stores its load tests + vcsrepo { '/home/gatling/govuk-load-testing': + ensure => present, + provider => git, + source => $repo, + revision => $commit, + force => true, + } + + # install the JRE and JDK on the Gatling instance + include ::govuk_java::openjdk8::jre + include ::govuk_java::openjdk8::jdk + class { 'govuk_java::set_defaults': + jdk => 'openjdk8', + jre => 'openjdk8', + } + + apt::source { 'govuk-gatling': + location => "http://${apt_mirror_hostname}/govuk-gatling", + release => 'trusty', + architecture => $::architecture, + repos => 'main', + key => '3803E444EB0235822AA36A66EC5FE1A937E3ACBB', + } + + package { 'govuk-gatling': + ensure => latest, + name => 'gatling-3.1.3.deb', + require => Apt::Source['govuk-gatling'], + } + + file { '/usr/local/bin/gatling': + ensure => directory, + mode => '0777', + recurse => true, + require => Package['govuk-gatling'], + } + + include nginx + nginx::config::site { 'gatling_service': + content => template('govuk/node/s_gatling/gatling_cluster_vhost.conf.erb'), + } +} diff --git a/modules/govuk/templates/node/s_gatling/gatling_cluster_vhost.conf.erb b/modules/govuk/templates/node/s_gatling/gatling_cluster_vhost.conf.erb new file mode 100644 index 0000000000..da3b807acd --- /dev/null +++ b/modules/govuk/templates/node/s_gatling/gatling_cluster_vhost.conf.erb @@ -0,0 +1,12 @@ +server { + server_name gatling.* gatling-origin.*; + root <%= @root_dir -%>; + + access_log /var/log/nginx/gatling-access.log timed_combined; + access_log /var/log/nginx/gatling-json.event.access.log json_event; + error_log /var/log/nginx/gatling-error.log; + + location / { + autoindex on; + } +} diff --git a/modules/govuk_scripts/templates/govuk_node_list_aws.erb b/modules/govuk_scripts/templates/govuk_node_list_aws.erb index ec294cd8f9..71da9ea345 100644 --- a/modules/govuk_scripts/templates/govuk_node_list_aws.erb +++ b/modules/govuk_scripts/templates/govuk_node_list_aws.erb @@ -21,7 +21,7 @@ def ec2_nodes(stackname, nodeclass=None): if nodeclass: response = client.describe_instances( Filters=[ - {'Name': 'tag:aws_stackname', 'Values': [stackname]}, + {'Name': 'tag:aws_stackname', 'Values': [stackname, 'govuk']}, {'Name': 'tag:aws_migration', 'Values': [nodeclass]}, {'Name': 'instance-state-name', 'Values': ['running']} ] @@ -29,7 +29,7 @@ def ec2_nodes(stackname, nodeclass=None): else: response = client.describe_instances( Filters=[ - {'Name': 'tag:aws_stackname', 'Values': [stackname]}, + {'Name': 'tag:aws_stackname', 'Values': [stackname, 'govuk']}, {'Name': 'instance-state-name','Values': ['running']} ] ) @@ -47,7 +47,7 @@ def ec2_nodes_list_with_puppet_class(stackname): response = client.describe_instances( Filters=[ - {'Name': 'tag:aws_stackname', 'Values': [stackname]}, + {'Name': 'tag:aws_stackname', 'Values': [stackname, 'govuk']}, {'Name': 'instance-state-name','Values': ['running']} ] ) @@ -72,7 +72,7 @@ def ec2_classes(stackname): response = client.describe_instances( Filters=[ - {'Name': 'tag:aws_stackname', 'Values': [stackname]}, + {'Name': 'tag:aws_stackname', 'Values': [stackname, 'govuk']}, {'Name': 'instance-state-name','Values': ['running']} ] ) diff --git a/modules/hosts/manifests/purge.pp b/modules/hosts/manifests/purge.pp index 01d25d782d..d5a27d4a3f 100644 --- a/modules/hosts/manifests/purge.pp +++ b/modules/hosts/manifests/purge.pp @@ -22,6 +22,7 @@ 'mongo-api-1', 'prometheus-1', 'search-1', + 'gatling-1', ] if ! ($::hostname in $whitelist) {