diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d254178b..54923f33 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,26 +1,15 @@ -name: Test and Publish Mini +name: Publish Mini on: push: jobs: - test: - name: Test and publish artifacts - runs-on: ubuntu-18.04 + publish: + name: Publish artifacts + runs-on: ubuntu-22.04 steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Check Go version - run: go version - - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -y language-pack-en python-pip libffi-dev libssl-dev python-dev - sudo pip install --upgrade pip - sudo pip install markupsafe==1.1.1 setuptools==40.8.0 ansible==2.8.1 paramiko==1.16.0 + - uses: actions/checkout@v3 - name: Provision a local Mini instance run: ansible-playbook -i $GITHUB_WORKSPACE/provisioning/inventory $GITHUB_WORKSPACE/provisioning/local_setup.yml --connection=local --become @@ -35,10 +24,8 @@ jobs: if: startsWith(github.ref, 'refs/tags/') uses: 'google-github-actions/setup-gcloud@v0' - - name: Extract tag from ref - if: startsWith(github.ref, 'refs/tags/') - id: get_tag - run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | sed "s/refs\/tags\///") + - name: SSH config for Ansible + run: mkdir ~/.ssh && echo -e "Host 127.0.0.1\nHostKeyAlgorithms +ssh-rsa\nPubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config - name: Publish artifact based on cloud and size if: startsWith(github.ref, 'refs/tags/') @@ -46,4 +33,4 @@ jobs: AWS_DEPLOY_ACCESS_KEY: ${{ secrets.AWS_DEPLOY_ACCESS_KEY }} AWS_DEPLOY_SECRET_KEY: ${{ secrets.AWS_DEPLOY_SECRET_KEY }} GOOGLE_APPLICATION_CREDENTIALS_JSON_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON_BASE64 }} - run: $GITHUB_WORKSPACE/.github/workflows/deploy.sh ${{ steps.get_tag.outputs.VERSION }} + run: $GITHUB_WORKSPACE/.github/workflows/deploy.sh ${{ github.ref_name }} \ No newline at end of file diff --git a/Packerfile.json b/Packerfile.json index 9ee10232..1bb37c2d 100644 --- a/Packerfile.json +++ b/Packerfile.json @@ -13,7 +13,7 @@ "filters": { "virtualization-type": "hvm", "architecture": "x86_64", - "name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*", + "name": "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*", "root-device-type": "ebs" }, "owners": ["099720109477"], @@ -21,7 +21,7 @@ }, "ssh_username": "ubuntu", "tags": { - "OS_Version": "Ubuntu-18.04", + "OS_Version": "Ubuntu-22.04", "Release": "{{user `aws_version`}}" }, "type": "amazon-ebs" @@ -32,7 +32,7 @@ "image_name": "{{user `gcp_image_name`}}", "machine_type": "{{user `gcp_machine_type`}}", "project_id": "snowplow-images", - "source_image_family": "ubuntu-1804-lts", + "source_image_family": "ubuntu-2204-lts", "ssh_username": "ubuntu", "zone": "us-central1-a" } diff --git a/Vagrantfile b/Vagrantfile index 9b725f99..985b5566 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,6 @@ Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/bionic64" + config.vm.box = "ubuntu/jammy64" config.vm.hostname = "snowplow-mini" config.ssh.forward_agent = true diff --git a/integration/integration_test.sh b/integration/integration_test.sh deleted file mode 100755 index e251b493..00000000 --- a/integration/integration_test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Send good and bad events, and test that the default redirect path is disabled -COUNTER=0 -while [ $COUNTER -lt 10 ]; do - curl http://localhost:8080/i?e=pv - curl http://localhost:8080/i - curl http://localhost:8080/r/tp2 - let COUNTER=COUNTER+1 -done -sleep 30 - -# Assertions -good_count="$(curl --silent -XGET 'http://localhost:9200/good/good/_count' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["count"]')" -bad_count="$(curl --silent -XGET 'http://localhost:9200/bad/bad/_count' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["count"]')" - -echo "Event Counts:" -echo " - Good: ${good_count}" -echo " - Bad: ${bad_count}" - -if [[ "${good_count}" -eq "10" ]] && [[ "${bad_count}" -eq "10" ]]; then - exit 0 -else - exit 1 -fi diff --git a/provisioning/local_setup.yml b/provisioning/local_setup.yml index 3c89858b..df33f302 100644 --- a/provisioning/local_setup.yml +++ b/provisioning/local_setup.yml @@ -3,7 +3,7 @@ hosts: all roles: - - ansible-go + - go - nodejs - typescript - packer diff --git a/provisioning/publish.yml b/provisioning/publish.yml index 99402670..8631c525 100644 --- a/provisioning/publish.yml +++ b/provisioning/publish.yml @@ -1,6 +1,6 @@ --- # This playbook is used for provisioning of the AMI -# UI and executables file are made ready in the vagrant environment +# UI and executables file are made ready locally in Github Actions # They are only copied into the AMI here - name: apply all scripts hosts: all @@ -10,4 +10,4 @@ - sp_mini_4_setup_apps - sp_mini_6_copy_ui_folders - sp_mini_7_setup_init - - docker + - docker \ No newline at end of file diff --git a/provisioning/resources/control-plane/restart_services.go b/provisioning/resources/control-plane/restart_services.go index 09e607cc..dbd90513 100644 --- a/provisioning/resources/control-plane/restart_services.go +++ b/provisioning/resources/control-plane/restart_services.go @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 Snowplow Analytics Ltd. + * Copyright (c) 2016-2023 Snowplow Analytics Ltd. * All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, @@ -44,7 +44,7 @@ func restartSPService(service string) (error, int) { } else { if serviceName, ok := initMap[service]; ok { restartCommandArgs := []string{"restart", serviceName} - cmd := exec.Command("/usr/local/bin/docker-compose", restartCommandArgs...) + cmd := exec.Command("docker-compose", restartCommandArgs...) cmd.Dir = "/home/ubuntu/snowplow" err := cmd.Run() if err != nil { @@ -58,7 +58,7 @@ func restartSPService(service string) (error, int) { func restartSPServices() error { restartCommandArgs := []string{"-f", "/home/ubuntu/snowplow/docker-compose.yml", "restart"} - cmd := exec.Command("/usr/local/bin/docker-compose", restartCommandArgs...) + cmd := exec.Command("docker-compose", restartCommandArgs...) cmd.Dir = "/home/ubuntu/snowplow" err := cmd.Run() if err != nil { diff --git a/provisioning/resources/init/snowplow_mini.service b/provisioning/resources/init/snowplow_mini.service index 01039d19..589574dc 100644 --- a/provisioning/resources/init/snowplow_mini.service +++ b/provisioning/resources/init/snowplow_mini.service @@ -7,9 +7,9 @@ Type=oneshot RemainAfterExit=true WorkingDirectory=/home/ubuntu/snowplow ExecStartPre=/usr/sbin/service docker restart -ExecStartPre=/usr/local/bin/docker-compose down -ExecStart=/usr/local/bin/docker-compose up -d -ExecStop=/usr/local/bin/docker-compose down +ExecStartPre=docker-compose down +ExecStart=docker-compose up -d +ExecStop=docker-compose down [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/provisioning/roles/ansible-go/README.md b/provisioning/roles/ansible-go/README.md deleted file mode 100644 index dbf59f9e..00000000 --- a/provisioning/roles/ansible-go/README.md +++ /dev/null @@ -1,37 +0,0 @@ -Go -======== - -Ansible role that installs [Go](https://golang.org/). The latest stable release that has been compiled for x86 64-bit Linux systems is installed by default, and different platforms and versions are supported by modifying the role variables. - -Role Variables --------------- - -All of these variables are optional and should only be changed if you need to install a different version of Go (e.g. if you are installing on FreeBSD, or if you need to use an earlier release). - -`go_tarball`: The tarball that you want to install. A list of options can be found on the [Go Downloads page](https://golang.org/dl/). The default is the official x86 64-bit Linux tarball for the latest stable release. - -`go_tarball_checksum`: This variable specifies the algorithm and checksum for the tarball that you want to install (e.g. `sha1:c7d78ba4df574b5f9a9bb5d17505f40c4d89b81c` or `sha256:a96cce8ce43a9bf9b2a4c7d470bc7ee0cb00410da815980681c8353218dcf146`). The default is the SHA256 checksum of the official x86 64-bit tarball for the latest stable release. Checksums can be found on the [Go Download Page](https://golang.org/dl/). - -`go_version_target`: The string that the `go version` command is expected to return (e.g. "go version go1.2.1 linux/amd64"). This variable is used to control whether or not the Go tarball should be extracted, thereby upgrading (or downgrading) a previously installed copy. If the installed version already matches the target, the extraction step is skipped. - -`go_download_location`: The full download URL. This variable simply appends the `go_tarball` variable onto the Go Download URL. This should not need to be modified. - -`set_go_path`: Whether or not to set the GOPATH for all users. The default is `true`. - -License -------- - -The MIT License (MIT) - -Copyright (c) 2013-2016 Joshua Lund - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Author Information ------------------- - -You can find me on [Twitter](https://twitter.com/joshualund), and on [GitHub](https://github.com/jlund/). I also occasionally blog at [MissingM](https://missingm.co). diff --git a/provisioning/roles/ansible-go/defaults/main.yml b/provisioning/roles/ansible-go/defaults/main.yml deleted file mode 100644 index 654f7ec4..00000000 --- a/provisioning/roles/ansible-go/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -go_tarball: "go1.12.5.linux-amd64.tar.gz" -go_tarball_checksum: "sha256:aea86e3c73495f205929cfebba0d63f1382c8ac59be081b6351681415f4063cf" -go_version_target: "go version go1.12.5 linux/amd64" -set_go_path: true diff --git a/provisioning/roles/ansible-go/files/go-bin.sh b/provisioning/roles/ansible-go/files/go-bin.sh deleted file mode 100644 index 680c12af..00000000 --- a/provisioning/roles/ansible-go/files/go-bin.sh +++ /dev/null @@ -1 +0,0 @@ -export PATH=$PATH:/usr/local/go/bin diff --git a/provisioning/roles/ansible-go/files/go-path.sh b/provisioning/roles/ansible-go/files/go-path.sh deleted file mode 100644 index 5f4ffac8..00000000 --- a/provisioning/roles/ansible-go/files/go-path.sh +++ /dev/null @@ -1,2 +0,0 @@ -export GOPATH=$HOME/go -export PATH=$GOPATH/bin:$PATH diff --git a/provisioning/roles/ansible-go/meta/main.yml b/provisioning/roles/ansible-go/meta/main.yml deleted file mode 100644 index 55c97f94..00000000 --- a/provisioning/roles/ansible-go/meta/main.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -galaxy_info: - author: "Joshua Lund" - description: "Ansible role that installs Go (https://golang.org/). The latest stable release that has been compiled for x86 64-bit Linux systems is installed by default, and different platforms and versions are supported by modifying the role variables." - license: MIT - min_ansible_version: 2.0 - platforms: - - name: EL - versions: - - all - - name: GenericUNIX - versions: - - all - - name: Fedora - versions: - - all - - name: opensuse - versions: - - all - - name: GenericBSD - versions: - - all - - name: FreeBSD - versions: - - all - - name: Ubuntu - versions: - - all - - name: SLES - versions: - - all - - name: GenericLinux - versions: - - all - - name: Debian - versions: - - all - categories: - - development -dependencies: [] diff --git a/provisioning/roles/ansible-go/tasks/main.yml b/provisioning/roles/ansible-go/tasks/main.yml deleted file mode 100644 index 20f18a96..00000000 --- a/provisioning/roles/ansible-go/tasks/main.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: Download the Go tarball - become: yes - get_url: - url: "{{ go_download_location }}" - dest: /usr/local/src/{{ go_tarball }} - checksum: "{{ go_tarball_checksum }}" - -- name: Register the current Go version (if any) - become: yes - command: /usr/local/go/bin/go version - ignore_errors: yes - register: go_version - changed_when: false - -- name: Remove old installation of Go - become: yes - file: - path: /usr/local/go - state: absent - when: go_version is failed or go_version.stdout != go_version_target - -- name: Extract the Go tarball if Go is not yet installed or not the desired version - become: yes - unarchive: - src: /usr/local/src/{{ go_tarball }} - dest: /usr/local - copy: no - when: go_version is failed or go_version.stdout != go_version_target - -- name: Add the Go bin directory to the PATH environment variable for all users - become: yes - copy: - src: go-bin.sh - dest: /etc/profile.d - -- name: Set GOPATH for all users - become: yes - copy: - src: go-path.sh - dest: /etc/profile.d - when: set_go_path|bool diff --git a/provisioning/roles/ansible-go/vars/main.yml b/provisioning/roles/ansible-go/vars/main.yml deleted file mode 100644 index 7618a612..00000000 --- a/provisioning/roles/ansible-go/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -go_download_location: "https://storage.googleapis.com/golang/{{ go_tarball }}" diff --git a/provisioning/roles/common_vars.yml b/provisioning/roles/common_vars.yml index 2c58f4c1..08dd72f4 100644 --- a/provisioning/roles/common_vars.yml +++ b/provisioning/roles/common_vars.yml @@ -1,5 +1,6 @@ --- -main_dir: "/home/ubuntu/snowplow" +home_dir: "/home/ubuntu" +main_dir: "{{home_dir}}/snowplow" configs_dir: "{{main_dir}}/configs" staging_dir: "{{main_dir}}/staging" executables_dir: "{{main_dir}}/bin" diff --git a/provisioning/roles/docker/tasks/main.yml b/provisioning/roles/docker/tasks/main.yml index 12c27600..1c0ec4d0 100644 --- a/provisioning/roles/docker/tasks/main.yml +++ b/provisioning/roles/docker/tasks/main.yml @@ -1,24 +1,23 @@ --- - include_vars: ../../common_vars.yml -- name: Setup the docker repository and install docker +- name: Install ca-certificates curl gnupg become: yes - shell: | - apt-get update - apt-get install apt-transport-https ca-certificates curl software-properties-common --yes - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - apt-get update && apt-get install docker-ce --yes + shell: sudo apt-get install ca-certificates curl gnupg -- name: Download docker-compose +- name: Add Docker’s official GPG key become: yes - shell: curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose + shell: | + sudo install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + sudo chmod a+r /etc/apt/keyrings/docker.gpg -- name: Apply executable permissions to the docker-compose binary +- name: Set up Docker repo become: yes - args: - warn: false - shell: chmod +x /usr/local/bin/docker-compose + shell: echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list + +- name: Install docker-compose + apt: name=docker-compose state=latest - name: Copy docker-compose.yml and its environment file copy: src={{ item.src }} dest={{ item.dest }} owner=ubuntu group=ubuntu mode=0644 @@ -28,15 +27,13 @@ - name: Create & set permissions of elasticsearch data directory become: yes - args: - warn: false shell: rm -rf {{main_dir}}/elasticsearch/data && mkdir {{main_dir}}/elasticsearch/data && chown -R 1000:1000 {{main_dir}}/elasticsearch/data - name: Increase mmap count to recommended 262144 for Elasticsearch become: yes shell: echo "vm.max_map_count=262144" >> /etc/sysctl.conf && service procps restart -- name: Deploy snowplow mini +- name: Start snowplow mini (docker-compose up) become: yes shell: cd {{main_dir}} && docker-compose up -d && sleep 20 diff --git a/provisioning/roles/go/tasks/main.yml b/provisioning/roles/go/tasks/main.yml new file mode 100644 index 00000000..172c8cbd --- /dev/null +++ b/provisioning/roles/go/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Install Go + apt: name=golang-go state=latest diff --git a/provisioning/roles/nodejs/.gitignore b/provisioning/roles/nodejs/.gitignore deleted file mode 100644 index c9b2377e..00000000 --- a/provisioning/roles/nodejs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.retry -tests/test.sh diff --git a/provisioning/roles/nodejs/LICENSE b/provisioning/roles/nodejs/LICENSE deleted file mode 100644 index 4275cf3c..00000000 --- a/provisioning/roles/nodejs/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Jeff Geerling - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/provisioning/roles/nodejs/README.md b/provisioning/roles/nodejs/README.md deleted file mode 100644 index 94142737..00000000 --- a/provisioning/roles/nodejs/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Ansible Role: Node.js - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nodejs.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nodejs) - -Installs Node.js on RHEL/CentOS or Debian/Ubuntu. - -## Requirements - -Requires the EPEL repository on RedHat/CentOS (you can install it by simply adding the `geerlingguy.repo-epel` role to your playbook). - -## Role Variables - -Available variables are listed below, along with default values (see `defaults/main.yml`): - - nodejs_version: "6.x" - -The Node.js version to install. "6.x" is the default and works on most supported OSes. Other versions such as "0.12", "4.x", "5.x", "6.x", etc. should work on the latest versions of Debian/Ubuntu and RHEL/CentOS. - - nodejs_install_npm_user: "{{ ansible_ssh_user }}" - -The user for whom the npm packages will be installed can be set here, this defaults to `ansible_user`. - - npm_config_prefix: "/usr/local/lib/npm" - -The global installation directory. This should be writeable by the `nodejs_install_npm_user`. - - npm_config_unsafe_perm: "false" - -Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail. - - nodejs_npm_global_packages: [] - -A list of npm packages with a `name` and (optional) `version` to be installed globally. For example: - - nodejs_npm_global_packages: - # Install a specific version of a package. - - name: jslint - version: 0.9.3 - # Install the latest stable release of a package. - - name: node-sass - # This shorthand syntax also works (same as previous example). - - node-sass - - - nodejs_package_json_path: "" - -Set a path pointing to a particular `package.json` (e.g. `"/var/www/app/package.json"`). This will install all of the defined packages globally using Ansible's `npm` module. - -## Dependencies - -None. - -## Example Playbook - - - hosts: utility - vars_files: - - vars/main.yml - roles: - - geerlingguy.nodejs - -*Inside `vars/main.yml`*: - - nodejs_npm_global_packages: - - name: jslint - - name: node-sass - -## License - -MIT / BSD - -## Author Information - -This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/provisioning/roles/nodejs/defaults/main.yml b/provisioning/roles/nodejs/defaults/main.yml deleted file mode 100644 index f862788b..00000000 --- a/provisioning/roles/nodejs/defaults/main.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Set the version of Node.js to install ("0.10", "0.12", "4.x", "5.x", "6.x"). -# Version numbers from Nodesource: https://github.com/nodesource/distributions -nodejs_version: "6.x" - -# The user for whom the npm packages will be installed. -# nodejs_install_npm_user: username - -# The directory for global installations. -npm_config_prefix: "/usr/local/lib/npm" - -# Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail. -npm_config_unsafe_perm: "false" - -# Define a list of global packages to be installed with NPM. -nodejs_npm_global_packages: [] -# # Install a specific version of a package. -# - name: jslint -# version: 0.9.3 -# # Install the latest stable release of a package. -# - name: node-sass -# # This shorthand syntax also works (same as previous example). -# - node-sass - -# The path of a package.json file used to install packages globally. -nodejs_package_json_path: "" diff --git a/provisioning/roles/nodejs/meta/main.yml b/provisioning/roles/nodejs/meta/main.yml deleted file mode 100644 index 8925daaf..00000000 --- a/provisioning/roles/nodejs/meta/main.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: Node.js installation for Linux - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 1.9 - platforms: - - name: EL - versions: - - 6 - - 7 - - name: Debian - versions: - - all - - name: Ubuntu - versions: - - precise - - raring - - saucy - - trusty - - xenial - galaxy_tags: - - development - - web diff --git a/provisioning/roles/nodejs/tasks/main.yml b/provisioning/roles/nodejs/tasks/main.yml index 2a78073a..87365b74 100644 --- a/provisioning/roles/nodejs/tasks/main.yml +++ b/provisioning/roles/nodejs/tasks/main.yml @@ -1,41 +1,6 @@ --- -- include: setup-RedHat.yml - when: ansible_os_family == 'RedHat' +- name: Setup NodeJS repo + shell: 'curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -' -- include: setup-Debian.yml - when: ansible_os_family == 'Debian' - -- name: Define nodejs_install_npm_user - set_fact: - nodejs_install_npm_user: "{{ ansible_user_id | default(ansible_user) | default(lookup('env', 'USER')) }}" - when: nodejs_install_npm_user is not defined - -- name: Create npm global directory - file: - path: "{{ npm_config_prefix }}" - owner: "{{ nodejs_install_npm_user }}" - group: "{{ nodejs_install_npm_user }}" - state: directory - -- name: Add npm_config_prefix bin directory to global $PATH. - template: - src: npm.sh.j2 - dest: /etc/profile.d/npm.sh - mode: 0644 - -- name: Ensure npm global packages are installed. - npm: - name: "{{ item.name | default(item) }}" - version: "{{ item.version | default('latest') }}" - global: yes - state: latest - environment: - NPM_CONFIG_PREFIX: "{{ npm_config_prefix }}" - NODE_PATH: "{{ npm_config_prefix }}/lib/node_modules" - NPM_CONFIG_UNSAFE_PERM: "{{ npm_config_unsafe_perm }}" - with_items: "{{ nodejs_npm_global_packages }}" - -- name: Install packages defined in a given package.json. - npm: - path: "{{ nodejs_package_json_path }}" - when: nodejs_package_json_path is defined and nodejs_package_json_path +- name: Install NodeJS + apt: name=nodejs state=latest diff --git a/provisioning/roles/nodejs/tasks/setup-Debian.yml b/provisioning/roles/nodejs/tasks/setup-Debian.yml deleted file mode 100644 index 9eed915a..00000000 --- a/provisioning/roles/nodejs/tasks/setup-Debian.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Ensure apt-transport-https is installed. - apt: name=apt-transport-https state=present - -- name: Install latest ca-certificates. - apt: name=ca-certificates state=latest - -- name: Add Nodesource apt key. - apt_key: - url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280 - id: "68576280" - state: present - -- name: Add NodeSource repositories for Node.js. - apt_repository: - repo: "{{ item }}" - state: present - with_items: - - "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" - - "deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main" - register: node_repo - -- name: Update apt cache if repo was added. - apt: update_cache=yes - when: node_repo.changed - -- name: Ensure Node.js and npm are installed. - apt: "name=nodejs={{ nodejs_version|regex_replace('x', '') }}* state=present" diff --git a/provisioning/roles/nodejs/tasks/setup-RedHat.yml b/provisioning/roles/nodejs/tasks/setup-RedHat.yml deleted file mode 100644 index ea6292b1..00000000 --- a/provisioning/roles/nodejs/tasks/setup-RedHat.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Set up the Nodesource RPM directory for Node.js > 0.10. - set_fact: - nodejs_rhel_rpm_dir: "pub_{{ nodejs_version }}" - when: nodejs_version != '0.10' - -- name: Set up the Nodesource RPM variable for Node.js == 0.10. - set_fact: - nodejs_rhel_rpm_dir: "pub" - when: nodejs_version == '0.10' - -- name: Import Nodesource RPM key (CentOS < 7). - rpm_key: - key: http://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL - state: present - when: ansible_distribution_major_version|int < 7 - -- name: Import Nodesource RPM key (CentOS 7+).. - rpm_key: - key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL - state: present - when: ansible_distribution_major_version|int >= 7 - -- name: Add Nodesource repositories for Node.js (CentOS < 7). - yum: - name: "http://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm" - state: present - when: ansible_distribution_major_version|int < 7 - -- name: Add Nodesource repositories for Node.js (CentOS 7+). - yum: - name: "https://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm" - state: present - when: ansible_distribution_major_version|int >= 7 - -- name: Ensure Node.js and npm are installed. - yum: "name=nodejs-{{ nodejs_version[0] }}.* state=present enablerepo='epel,nodesource'" diff --git a/provisioning/roles/nodejs/templates/npm.sh.j2 b/provisioning/roles/nodejs/templates/npm.sh.j2 deleted file mode 100644 index 67caa789..00000000 --- a/provisioning/roles/nodejs/templates/npm.sh.j2 +++ /dev/null @@ -1,3 +0,0 @@ -export PATH={{ npm_config_prefix }}/bin:$PATH -export NPM_CONFIG_PREFIX={{ npm_config_prefix }} -export NODE_PATH=$NODE_PATH:{{ npm_config_prefix }}/lib/node_modules diff --git a/provisioning/roles/nodejs/tests/README.md b/provisioning/roles/nodejs/tests/README.md deleted file mode 100644 index 6fb21172..00000000 --- a/provisioning/roles/nodejs/tests/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Ansible Role tests - -To run the test playbook(s) in this directory: - - 1. Install and start Docker. - 1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`: - - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` - 1. Make the test shim executable: `chmod +x tests/test.sh`. - 1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh` - -If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)` diff --git a/provisioning/roles/nodejs/tests/test.yml b/provisioning/roles/nodejs/tests/test.yml deleted file mode 100644 index 209dcf49..00000000 --- a/provisioning/roles/nodejs/tests/test.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- hosts: all - - vars: - nodejs_version: "5.x" - nodejs_install_npm_user: root - npm_config_prefix: /root/.npm-global - npm_config_unsafe_perm: "true" - nodejs_npm_global_packages: - - node-sass - - name: jslint - version: 0.9.6 - - name: yo - - pre_tasks: - - name: Update apt cache. - apt: update_cache=yes cache_valid_time=600 - when: ansible_os_family == 'Debian' - - roles: - - role_under_test diff --git a/provisioning/roles/packer/defaults/main.yml b/provisioning/roles/packer/defaults/main.yml deleted file mode 100644 index a9fa8b27..00000000 --- a/provisioning/roles/packer/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -packer_version: "1.4.1" diff --git a/provisioning/roles/packer/tasks/main.yml b/provisioning/roles/packer/tasks/main.yml index fa3d7aa5..ebc65c7e 100644 --- a/provisioning/roles/packer/tasks/main.yml +++ b/provisioning/roles/packer/tasks/main.yml @@ -1,16 +1,9 @@ --- -- name: Download Packer - become: yes - args: - warn: false - shell: curl -o {{ packer_install_dir }}/{{ packer_archive }}.zip {{ packer_url }} +- name: Add the HashiCorp GPG key + shell: 'curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -' -- name: Extract Packer - become: yes - unarchive: copy=no src={{ packer_install_dir }}/{{ packer_archive }}.zip dest={{ packer_install_dir }} +- name: Add the official HashiCorp Linux repository + shell: 'sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"' -- name: Remove downloaded packer_archive - become: yes - args: - warn: false - shell: "rm -f {{ packer_install_dir }}/{{ packer_archive }}.zip" +- name : Install packer + shell: 'sudo apt-get update && sudo apt-get install packer' diff --git a/provisioning/roles/sp_mini_3_build_go_projects/tasks/main.yml b/provisioning/roles/sp_mini_3_build_go_projects/tasks/main.yml index e3fa9922..d9107fd3 100644 --- a/provisioning/roles/sp_mini_3_build_go_projects/tasks/main.yml +++ b/provisioning/roles/sp_mini_3_build_go_projects/tasks/main.yml @@ -4,24 +4,22 @@ - name: Set variables set_fact: control_plane_dir: '{{playbook_dir}}/resources/control-plane' - go_bin: '/usr/local/go/bin' - go_path: "{{ lookup('env', 'HOME') }}/go" -- name: Get Control Plane dependencies - environment: - PATH: "{{ lookup('env','PATH') }}:{{ go_bin }}" - GOPATH: "{{ lookup('env', 'GOPATH') }}" - shell: | - until $(/usr/local/go/bin/go get github.com/BurntSushi/toml); do echo "github.com/BurntSushi/toml"; sleep 1; done - until $(/usr/local/go/bin/go get gopkg.in/pg.v5); do echo "gopkg.in/pg.v5"; sleep 1; done - until $(/usr/local/go/bin/go get github.com/trustelem/zxcvbn); do echo "github.com/trustelem/zxcvbn"; sleep 1; done - until $(/usr/local/go/bin/go get golang.org/x/crypto/bcrypt); do echo "golang.org/x/crypto/bcrypt"; sleep 1; done +- name: Add Go backports for old versions + become: yes + command: sudo add-apt-repository -y ppa:longsleep/golang-backports + +- name: Install Go 1.15 + become: yes + command: sudo apt install golang-1.15-go + +- name: Init Go module + become: yes + command: /usr/lib/go-1.15/bin/go mod init control-plane - name: Build Control Plane API become: yes - environment: - PATH: "{{ lookup('env','PATH') }}:{{ go_bin }}" - shell: "/usr/local/go/bin/go build -o {{control_plane_dir}}/snowplow-mini-control-plane-api {{control_plane_dir}}/*.go" + shell: "/usr/lib/go-1.15/bin/go build -o {{control_plane_dir}}/snowplow-mini-control-plane-api {{control_plane_dir}}/*.go" - name: Copy Control Plane API to executables dir become: yes diff --git a/provisioning/roles/sp_mini_4_setup_apps/tasks/main.yml b/provisioning/roles/sp_mini_4_setup_apps/tasks/main.yml index 9f4a59d3..4ec97526 100644 --- a/provisioning/roles/sp_mini_4_setup_apps/tasks/main.yml +++ b/provisioning/roles/sp_mini_4_setup_apps/tasks/main.yml @@ -37,6 +37,4 @@ - name: Set owner of the main directory become: yes - args: - warn: false - shell: "chown -R ubuntu:ubuntu {{main_dir}} && chmod 755 -R {{main_dir}}" + shell: "chown -R ubuntu:ubuntu {{home_dir}} && chmod 755 -R {{home_dir}}" diff --git a/utils/scripts/user_data.sh b/utils/scripts/user_data.sh index 49412c51..d5afb102 100755 --- a/utils/scripts/user_data.sh +++ b/utils/scripts/user_data.sh @@ -8,7 +8,7 @@ password='password' iglu_server_super_uid='deadbeef-dead-beef-dead-beefdeadbeef' # DO NOT ALTER BELOW # -sudo /usr/local/bin/docker-compose -f /home/ubuntu/snowplow/docker-compose.yml restart iglu-server +docker-compose -f /home/ubuntu/snowplow/docker-compose.yml restart iglu-server sudo service snowplow_mini_control_plane_api restart sleep 10