diff --git a/.circleci/config.yml b/.circleci/config.yml index fc880bf92..f96bcd88a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,22 @@ jobs: paths: - "*" + fetch-plugins: + executor: golang + steps: + - attach_workspace: + at: ./artifacts + - run: + name: Download Plugins Tarball + command: curl -fL https://github.com/observiq/carbon-plugins/releases/latest/download/carbon-plugins.tar.gz -o ./artifacts/plugins.tar.gz + - run: + name: Download Plugins Zip + command: curl -fL https://github.com/observiq/carbon-plugins/releases/latest/download/carbon-plugins.zip -o ./artifacts/plugins.zip + - persist_to_workspace: + root: ./artifacts + paths: + - "*" + publish-github-release: docker: - image: cibuilds/github:0.10 @@ -380,9 +396,16 @@ workflows: - test-linux - test-macos - test-windows + - fetch-plugins: + filters: + branches: + ignore: /.*/ + tags: + only: /^v\d+\.\d+\.\d+.*/ - publish-github-release: requires: - build + - fetch-plugins filters: branches: ignore: /.*/ @@ -391,6 +414,7 @@ workflows: - publish-docker-release: requires: - build + - fetch-plugins filters: branches: ignore: /.*/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 395f68c79..459b58263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased - Add support for multiple encodings in the file input plugin +- Install scripts and docker image now include plugins from `carbon-plugins` repository ## [0.9.2] - 2020-07-13 ### Added diff --git a/Dockerfile b/Dockerfile index 3eb2c7af5..957733fcd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ FROM ubuntu:bionic -RUN mkdir -p /carbon_home/plugins +RUN mkdir -p /carbon_home ENV CARBON_HOME=/carbon_home RUN echo "pipeline:\n" >> /carbon_home/config.yaml RUN apt-get update && apt-get install -y systemd ca-certificates COPY ./artifacts/carbon_linux_amd64 /carbon_home/carbon +COPY ./artifacts/carbon-plugins.tar.gz /tmp/carbon-plugins.tar.gz +RUN tar -zxvf /tmp/carbon-plugins.tar.gz -C /carbon_home/ ENTRYPOINT /carbon_home/carbon \ --config /carbon_home/config.yaml \ --database /carbon_home/carbon.db \ diff --git a/scripts/unix-install.sh b/scripts/unix-install.sh index 2593f43c7..7acba8575 100755 --- a/scripts/unix-install.sh +++ b/scripts/unix-install.sh @@ -7,7 +7,8 @@ set -e # Agent Constants SERVICE_NAME="carbon" BINARY_NAME="carbon" -DOWNLOAD_BASE="https://github.com/observiq/carbon/releases/latest/download" +DOWNLOAD_BASE="https://github.com/observiq/carbon/releases" +PLUGINS_PACKAGE="carbon-plugins.tar.gz" # Script Constants PREREQS="curl hostname printf ps sed uname cut tar" @@ -131,9 +132,9 @@ usage() increase_indent USAGE=$(cat < ' '' "$script:binary_location" DarkCyan + Show-ColorText "$INDENT_WIDTH$script:agent_download_url" DarkCyan ' -> ' '' "$script:binary_location" DarkCyan try { $WebClient = New-Object System.Net.WebClient - $WebClient.DownloadFile($script:download_url, $script:binary_location) + $WebClient.DownloadFile($script:agent_download_url, $script:binary_location) Complete } catch { @@ -417,6 +424,68 @@ new-module -name LogAgentInstall -scriptblock { Remove-Indent } + # This will download and extract plugins to the plugins directory. + function Get-CarbonPlugins { + Show-Header "Downloading Carbon Plugins" + Add-Indent + Show-ColorText 'Downloading plugins. Please wait...' + Show-ColorText "$INDENT_WIDTH$script:plugins_download_url" DarkCyan ' -> ' '' "$script:agent_home\plugins.zip" DarkCyan + + try { + New-Item -Path "$script:agent_home\download\tmp" -ItemType "directory" + Complete + } + catch { + Failed + $error_message = $_.Exception.Message -replace 'Exception calling.*?: ', '' + Exit-Error $MyInvocation.ScriptLineNumber "Failed to create tmp directory plugins: $error_message" + } + + try { + $WebClient = New-Object System.Net.WebClient + $WebClient.DownloadFile($script:plugins_download_url, "$script:agent_home\download\plugins.zip") + Complete + } + catch { + Failed + $error_message = $_.Exception.Message -replace 'Exception calling.*?: ', '' + Exit-Error $MyInvocation.ScriptLineNumber "Failed to download plugins: $error_message" + } + + try { + [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null + [System.IO.Compression.ZipFile]::ExtractToDirectory("$script:agent_home\download\plugins.zip", "$script:agent_home\download") + Complete + } + catch { + Failed + $error_message = $_.Exception.Message -replace 'Exception calling.*?: ', '' + Exit-Error $MyInvocation.ScriptLineNumber "Failed to expand plugins archive: $error_message" + } + + try { + Copy-Item -Path "$script:agent_home\download\plugins\*.yaml" -Destination "$script:agent_home\plugins" + Complete + } + catch { + Failed + $error_message = $_.Exception.Message -replace 'Exception calling.*?: ', '' + Exit-Error $MyInvocation.ScriptLineNumber "Failed to relocate plugins: $error_message" + } + + try { + Remove-Item -Path "$script:agent_home\download" -Recurse + Complete + } + catch { + Failed + $error_message = $_.Exception.Message -replace 'Exception calling.*?: ', '' + Exit-Error $MyInvocation.ScriptLineNumber "Failed to clean up download: $error_message" + } + + Remove-Indent + } + # This will remove the agent service. function Remove-AgentService { $service = Get-Service $SERVICE_NAME -ErrorAction SilentlyContinue @@ -593,8 +662,8 @@ pipeline: [Alias('y', 'accept_defaults')] [string]$script:accept_defaults, - [Alias('d', 'download_url')] - [string]$script:download_url, + [Alias('v', 'version')] + [string]$script:version, [Alias('i', 'install_dir')] [string]$script:install_dir = '', @@ -624,6 +693,7 @@ pipeline: Set-Permissions Remove-AgentService Get-CarbonBinary + Get-CarbonPlugins New-AgentConfig New-AgentService Complete-Install