diff --git a/README.md b/README.md index bd98a5f7..d613833d 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,14 @@ User Guide - The name of the database where you want to store your metrics. - The username and the password for this specific database. +You can select up to 3 physical disks that will be mounted as a single logical +volume to store the InfluxDB data. If you specify no disk, the data will +be stored on the root filesystem. In all cases, InfluxDB data will be +located in the */opt/influxdb* directory. + +For each disk, you can also specify the allocated size (in GB). If you don't +specify a value, the plugin will use all the free space of the disk. + Here is a screenshot of the fields ![InfluxDB-Grafana fields](./figures/influxdb-grafana-plugin.png "InfluxDB-Grafana fields") diff --git a/deployment_scripts/puppet/manifests/setup_disks.pp b/deployment_scripts/puppet/manifests/setup_disks.pp new file mode 100644 index 00000000..3ba82395 --- /dev/null +++ b/deployment_scripts/puppet/manifests/setup_disks.pp @@ -0,0 +1,27 @@ +$influxdb_grafana = hiera('influxdb_grafana') + +if $influxdb_grafana['node_name'] == hiera('user_node_name') { + + class { 'disk_management': } + + if ($influxdb_grafana['disk1']) { + disk_management::partition { "/dev/${influxdb_grafana['disk1']}": + size => $influxdb_grafana['disk1_size'], + require => Class['disk_management'], + } + } + + if ($influxdb_grafana['disk2']) { + disk_management::partition { "/dev/${influxdb_grafana['disk2']}": + size => $influxdb_grafana['disk2_size'], + require => Class['disk_management'], + } + } + + if ($influxdb_grafana['disk3']) { + disk_management::partition { "/dev/${influxdb_grafana['disk3']}": + size => $influxdb_grafana['disk3_size'], + require => Class['disk_management'], + } + } +} diff --git a/deployment_scripts/puppet/manifests/setup_influxdir.pp b/deployment_scripts/puppet/manifests/setup_influxdir.pp new file mode 100644 index 00000000..49eaf623 --- /dev/null +++ b/deployment_scripts/puppet/manifests/setup_influxdir.pp @@ -0,0 +1,33 @@ +$influxdb_grafana = hiera('influxdb_grafana') + +if $influxdb_grafana['node_name'] == hiera('user_node_name') { + + $directory = $influxdb_grafana['data_dir'] + $disks = split($::unallocated_pvs, ',') + + validate_array($disks) + + user { 'influxdb': + ensure => present, + system => true, + shell => '/sbin/nologin', + } + + if empty($disks) { + file { $directory: + ensure => 'directory', + owner => 'influxdb', + group => 'influxdb', + require => User['influxdb'], + } + } else { + disk_management::lvm_fs { $directory: + owner => 'influxdb', + group => 'influxdb', + disks => $disks, + lv_name => 'influxdb-data', + vg_name => 'influxdb', + require => User['influxdb'], + } + } +} diff --git a/environment_config.yaml b/environment_config.yaml index afef73ef..2c0b2110 100644 --- a/environment_config.yaml +++ b/environment_config.yaml @@ -49,3 +49,69 @@ attributes: regex: source: '^[\S]{4,}$' error: "You must provide a password with at least 4 characters" + + # Parameter hidden in the UI on purpose + data_dir: + value: '/opt/influxdb' + label: 'InfluxDB storage directory' + description: 'Directory used by InfluxDB to store data' + weight: 70 + type: "text" + restrictions: + - condition: true + action: hide + + disk1: + value: '' + label: 'Disk 1' + description: 'Disk device used to store InfluxDB data (for instance sda or sdb or another device). Leave it empty to use "/".' + weight: 80 + type: "text" + + disk1_size: + value: '' + label: 'Size' + description: 'in GB. Leave it empty to use all free space.' + weight: 90 + type: "text" + + disk2: + value: '' + label: 'Disk 2' + description: 'Disk device used to store InfluxDB data (for instance sdb).' + weight: 100 + type: "text" + restrictions: + - condition: "settings:influxdb_grafana.disk1.value == ''" + action: "disable" + + disk2_size: + value: '' + label: 'Size' + description: 'in GB. Leave it empty to use all free space.' + weight: 110 + type: "text" + restrictions: + - condition: "settings:influxdb_grafana.disk1.value == ''" + action: "disable" + + disk3: + value: '' + label: 'Disk 3' + description: 'Disk device used to store InfluxDB data (for instance sdc).' + weight: 120 + type: "text" + restrictions: + - condition: "settings:influxdb_grafana.disk2.value == ''" + action: "disable" + + disk3_size: + value: '' + label: 'Size' + description: 'in GB. Leave it empty to use all free space.' + weight: 130 + type: "text" + restrictions: + - condition: "settings:influxdb_grafana.disk2.value == ''" + action: "disable" + diff --git a/figures/influxdb-grafana-plugin.png b/figures/influxdb-grafana-plugin.png index 17ab4f24..c5cfb2c5 100644 Binary files a/figures/influxdb-grafana-plugin.png and b/figures/influxdb-grafana-plugin.png differ diff --git a/pre_build_hook b/pre_build_hook index c322b620..b4b3983b 100755 --- a/pre_build_hook +++ b/pre_build_hook @@ -17,6 +17,9 @@ NGINX_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/jfryman-nginx-0.2.2. FUEL_LIB_VERSION="6.0" FUEL_LIB_TARBALL_URL="https://github.com/stackforge/fuel-library/archive/${FUEL_LIB_VERSION}.tar.gz" +# Get the disk_management from fuel-plugin-elasticsearch-kibana +MODULE_DISK_MANAGEMENT="https://github.com/stackforge/fuel-plugin-elasticsearch-kibana/archive/master.tar.gz" + # Downloads needed RPM or DEB packages function download { case "$1" in @@ -37,7 +40,7 @@ download rpm http://get.influxdb.org/influxdb-0.8.8-1.x86_64.rpm # Install puppet manifests # Clean-up first -rm -rf ${MODULES}/{influxdb,nginx,staging,stdlib,concat,inifile} +rm -rf ${MODULES}/{influxdb,nginx,staging,stdlib,concat,inifile,disk_management,lvm} mkdir -p ${MODULES}/{influxdb,nginx,staging} # Include influxdb manifests, its dependendy and nginx. @@ -48,7 +51,12 @@ wget -qO- "${NGINX_TARBALL_URL}" | tar -C "${MODULES}/nginx" --strip-components= # Include dependent manifests from fuel-library wget -qO- "${FUEL_LIB_TARBALL_URL}" | \ tar -C "${MODULES}" --strip-components=3 -zxvf - \ - fuel-library-${FUEL_LIB_VERSION}/deployment/puppet/{stdlib,concat,inifile} + fuel-library-${FUEL_LIB_VERSION}/deployment/puppet/{stdlib,concat,inifile,lvm} + +# Include disk_management +wget -qO- "${MODULE_DISK_MANAGEMENT}" | \ + tar -C "${MODULES}" --strip-components=4 -xzvf - \ + fuel-plugin-elasticsearch-kibana-master/deployment_scripts/puppet/modules/disk_management # We need to embed grafana sources into the lma_monitoring_analytics module. GRAFANA_TARBALL_URL="http://grafanarel.s3.amazonaws.com/grafana-1.9.1.tar.gz" diff --git a/tasks.yaml b/tasks.yaml index 5a09fcb9..ab375929 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -7,6 +7,28 @@ puppet_modules: /etc/puppet/modules timeout: 720 +- role: ['base-os'] + stage: post_deployment + type: puppet + parameters: + puppet_manifest: puppet/manifests/setup_disks.pp + puppet_modules: puppet/modules + timeout: 600 + +- role: ['base-os'] + stage: post_deployment + type: reboot + parameters: + timeout: 600 + +- role: ['base-os'] + stage: post_deployment + type: puppet + parameters: + puppet_manifest: puppet/manifests/setup_influxdir.pp + puppet_modules: puppet/modules + timeout: 600 + - role: ['base-os'] stage: post_deployment type: puppet