From 8a5d60cce47184e1cecf8be37f883faf00eb24ed Mon Sep 17 00:00:00 2001 From: Michael Marquez Date: Mon, 19 Apr 2021 01:22:42 -0400 Subject: [PATCH] First Commit --- .gitignore | 3 ++ Vagrantfile | 73 +++++++++++++++++++++++++++ circleci-server.yaml | 8 +++ roles/docker/.travis.yml | 29 +++++++++++ roles/docker/README.md | 38 ++++++++++++++ roles/docker/defaults/main.yml | 2 + roles/docker/files/docker-gc-start.rc | 19 +++++++ roles/docker/files/docker-gc.service | 9 ++++ roles/docker/handlers/main.yml | 2 + roles/docker/meta/main.yml | 52 +++++++++++++++++++ roles/docker/tasks/main.yml | 73 +++++++++++++++++++++++++++ roles/docker/tests/inventory | 2 + roles/docker/tests/test.yml | 5 ++ roles/docker/vars/main.yml | 2 + roles/k3s/.travis.yml | 29 +++++++++++ roles/k3s/README.md | 38 ++++++++++++++ roles/k3s/defaults/main.yml | 2 + roles/k3s/handlers/main.yml | 2 + roles/k3s/meta/main.yml | 52 +++++++++++++++++++ roles/k3s/tasks/main.yml | 24 +++++++++ roles/k3s/templates/config.yaml.j2 | 1 + roles/k3s/tests/inventory | 2 + roles/k3s/tests/test.yml | 5 ++ roles/k3s/vars/main.yml | 2 + roles/kots/.travis.yml | 29 +++++++++++ roles/kots/README.md | 38 ++++++++++++++ roles/kots/defaults/main.yml | 2 + roles/kots/handlers/main.yml | 2 + roles/kots/meta/main.yml | 52 +++++++++++++++++++ roles/kots/tasks/main.yml | 8 +++ roles/kots/tests/inventory | 2 + roles/kots/tests/test.yml | 5 ++ roles/kots/vars/main.yml | 2 + roles/nomad/.travis.yml | 29 +++++++++++ roles/nomad/README.md | 38 ++++++++++++++ roles/nomad/defaults/main.yml | 2 + roles/nomad/files/nomad.service | 9 ++++ roles/nomad/handlers/main.yml | 2 + roles/nomad/meta/main.yml | 52 +++++++++++++++++++ roles/nomad/tasks/main.yml | 36 +++++++++++++ roles/nomad/templates/config.hcl.j2 | 18 +++++++ roles/nomad/tests/inventory | 2 + roles/nomad/tests/test.yml | 5 ++ roles/nomad/vars/main.yml | 1 + 44 files changed, 808 insertions(+) create mode 100644 .gitignore create mode 100644 Vagrantfile create mode 100644 circleci-server.yaml create mode 100644 roles/docker/.travis.yml create mode 100644 roles/docker/README.md create mode 100644 roles/docker/defaults/main.yml create mode 100644 roles/docker/files/docker-gc-start.rc create mode 100644 roles/docker/files/docker-gc.service create mode 100644 roles/docker/handlers/main.yml create mode 100644 roles/docker/meta/main.yml create mode 100644 roles/docker/tasks/main.yml create mode 100644 roles/docker/tests/inventory create mode 100644 roles/docker/tests/test.yml create mode 100644 roles/docker/vars/main.yml create mode 100644 roles/k3s/.travis.yml create mode 100644 roles/k3s/README.md create mode 100644 roles/k3s/defaults/main.yml create mode 100644 roles/k3s/handlers/main.yml create mode 100644 roles/k3s/meta/main.yml create mode 100644 roles/k3s/tasks/main.yml create mode 100644 roles/k3s/templates/config.yaml.j2 create mode 100644 roles/k3s/tests/inventory create mode 100644 roles/k3s/tests/test.yml create mode 100644 roles/k3s/vars/main.yml create mode 100644 roles/kots/.travis.yml create mode 100644 roles/kots/README.md create mode 100644 roles/kots/defaults/main.yml create mode 100644 roles/kots/handlers/main.yml create mode 100644 roles/kots/meta/main.yml create mode 100644 roles/kots/tasks/main.yml create mode 100644 roles/kots/tests/inventory create mode 100644 roles/kots/tests/test.yml create mode 100644 roles/kots/vars/main.yml create mode 100644 roles/nomad/.travis.yml create mode 100644 roles/nomad/README.md create mode 100644 roles/nomad/defaults/main.yml create mode 100644 roles/nomad/files/nomad.service create mode 100644 roles/nomad/handlers/main.yml create mode 100644 roles/nomad/meta/main.yml create mode 100644 roles/nomad/tasks/main.yml create mode 100644 roles/nomad/templates/config.hcl.j2 create mode 100644 roles/nomad/tests/inventory create mode 100644 roles/nomad/tests/test.yml create mode 100644 roles/nomad/vars/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d30f0f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vagrant +marquez-dev.yaml +k3s.yaml diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..58722c2 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,73 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "ubuntu/focal64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + config.vm.network "forwarded_port", guest: 8800, host: 8800 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + + config.vm.provider "virtualbox" do |v| + v.memory = 4096 + v.cpus = 2 + end + + config.vm.provision "ansible" do |ansible| + ansible.playbook = "circleci-server.yaml" + end + + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL +end diff --git a/circleci-server.yaml b/circleci-server.yaml new file mode 100644 index 0000000..e671743 --- /dev/null +++ b/circleci-server.yaml @@ -0,0 +1,8 @@ +--- +- hosts: all + become: true + roles: + - k3s + - docker + - nomad + - kots diff --git a/roles/docker/.travis.yml b/roles/docker/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/docker/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/docker/README.md b/roles/docker/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/docker/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml new file mode 100644 index 0000000..f0327f6 --- /dev/null +++ b/roles/docker/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for docker diff --git a/roles/docker/files/docker-gc-start.rc b/roles/docker/files/docker-gc-start.rc new file mode 100644 index 0000000..32b8f20 --- /dev/null +++ b/roles/docker/files/docker-gc-start.rc @@ -0,0 +1,19 @@ +#!/bin/bash +set -euo pipefail +timeout 1m docker pull circleci/docker-gc:1.0 +docker rm -f docker-gc || true +# Will return exit 0 if volume already exists +docker volume create docker-gc --label=keep +# --net=host is used to allow the container to talk to the local statsd agent +docker run \ + --rm \ + --interactive \ + --name "docker-gc" \ + --privileged \ + --net=host \ + --userns=host \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + --volume /var/lib/docker:/var/lib/docker:ro \ + --volume docker-gc:/state \ + "circleci/docker-gc:1.0" \ + -threshold "1000 KB" diff --git a/roles/docker/files/docker-gc.service b/roles/docker/files/docker-gc.service new file mode 100644 index 0000000..7e080d0 --- /dev/null +++ b/roles/docker/files/docker-gc.service @@ -0,0 +1,9 @@ +[Unit] +Description=Docker garbage collector +[Service] +Type=simple +Restart=always +ExecStart=/etc/docker-gc-start.rc +ExecStop=/bin/bash -c "docker rm -f docker-gc || true" +[Install] +WantedBy=cloud-init.target diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml new file mode 100644 index 0000000..a2bea01 --- /dev/null +++ b/roles/docker/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for docker diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/docker/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml new file mode 100644 index 0000000..50df18d --- /dev/null +++ b/roles/docker/tasks/main.yml @@ -0,0 +1,73 @@ +- name: Update Package Index + apt: + update_cache: yes + +- name: Install Docker Dependencies + apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - gnupg + - lsb-release + - python3-pip + +- name: Add Docker apt Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + keyring: /usr/share/keyrings/docker-archive-keyring.gpg + state: present + +- name: Add Docker Stable Repository + apt_repository: + repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable" + state: present + update_cache: yes + +- name: Install Docker + apt: + pkg: + - docker-ce + - docker-ce-cli + - containerd.io + +- name: Install Docker Python Library + pip: + name: docker + +- name: Copy Docker Garbage Collection Script + copy: + src: docker-gc-start.rc + dest: /etc/docker-gc-start.rc + mode: 0700 + + +- name: Copy Docker Garbage Collection Init Script + copy: + src: docker-gc.service + dest: /etc/systemd/system/docker-gc.service + mode: 0644 + owner: root + group: root + +- name: Enabling Docker Garbage Collection Service + systemd: + name: docker-gc.service + enabled: yes + +- name: Create CircleCI Privileged Network + community.docker.docker_network: + name: ci-privileged + driver: bridge + driver_options: + com.docker.network.bridge.name: ci-privileged + labels: + keep: "" + + + + + + + + diff --git a/roles/docker/tests/inventory b/roles/docker/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/docker/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/docker/tests/test.yml b/roles/docker/tests/test.yml new file mode 100644 index 0000000..7aabdb0 --- /dev/null +++ b/roles/docker/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - docker diff --git a/roles/docker/vars/main.yml b/roles/docker/vars/main.yml new file mode 100644 index 0000000..3806b4c --- /dev/null +++ b/roles/docker/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for docker diff --git a/roles/k3s/.travis.yml b/roles/k3s/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/k3s/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/k3s/README.md b/roles/k3s/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/k3s/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/k3s/defaults/main.yml b/roles/k3s/defaults/main.yml new file mode 100644 index 0000000..ab00659 --- /dev/null +++ b/roles/k3s/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for k3s diff --git a/roles/k3s/handlers/main.yml b/roles/k3s/handlers/main.yml new file mode 100644 index 0000000..9757f48 --- /dev/null +++ b/roles/k3s/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for k3s diff --git a/roles/k3s/meta/main.yml b/roles/k3s/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/k3s/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/k3s/tasks/main.yml b/roles/k3s/tasks/main.yml new file mode 100644 index 0000000..c8a4ff5 --- /dev/null +++ b/roles/k3s/tasks/main.yml @@ -0,0 +1,24 @@ +- name: Download K3s Installer + get_url: + url: https://get.k3s.io/ + dest: /tmp/install_k3s.sh + mode: '0444' + +- name: Create Rancher K3s Directory + file: + path: /etc/rancher/k3s + state: directory + +- name: Copy config.yaml + template: + src: config.yaml.j2 + dest: /etc/rancher/k3s/config.yaml + +- name: Install K3s + command: sh /tmp/install_k3s.sh + +- name: Copying Kubernetes Config from Remote Host + fetch: + src: /etc/rancher/k3s/k3s.yaml + dest: k3s.yaml + flat: yes diff --git a/roles/k3s/templates/config.yaml.j2 b/roles/k3s/templates/config.yaml.j2 new file mode 100644 index 0000000..3116731 --- /dev/null +++ b/roles/k3s/templates/config.yaml.j2 @@ -0,0 +1 @@ +write-kubeconfig-mode: "0664" diff --git a/roles/k3s/tests/inventory b/roles/k3s/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/k3s/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/k3s/tests/test.yml b/roles/k3s/tests/test.yml new file mode 100644 index 0000000..4c4f673 --- /dev/null +++ b/roles/k3s/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - k3s diff --git a/roles/k3s/vars/main.yml b/roles/k3s/vars/main.yml new file mode 100644 index 0000000..b6342f2 --- /dev/null +++ b/roles/k3s/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for k3s diff --git a/roles/kots/.travis.yml b/roles/kots/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/kots/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/kots/README.md b/roles/kots/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/kots/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/kots/defaults/main.yml b/roles/kots/defaults/main.yml new file mode 100644 index 0000000..25cf17a --- /dev/null +++ b/roles/kots/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for kots diff --git a/roles/kots/handlers/main.yml b/roles/kots/handlers/main.yml new file mode 100644 index 0000000..2723263 --- /dev/null +++ b/roles/kots/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for kots diff --git a/roles/kots/meta/main.yml b/roles/kots/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/kots/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/kots/tasks/main.yml b/roles/kots/tasks/main.yml new file mode 100644 index 0000000..d432892 --- /dev/null +++ b/roles/kots/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Download KOTS Install Script + get_url: + url: https://kots.io/install + dest: /tmp/install_kots.sh + mode: 0444 + +- name: Install KOTS + command: bash /tmp/install_kots.sh diff --git a/roles/kots/tests/inventory b/roles/kots/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/kots/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/kots/tests/test.yml b/roles/kots/tests/test.yml new file mode 100644 index 0000000..7b4d902 --- /dev/null +++ b/roles/kots/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - kots diff --git a/roles/kots/vars/main.yml b/roles/kots/vars/main.yml new file mode 100644 index 0000000..e866de0 --- /dev/null +++ b/roles/kots/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for kots diff --git a/roles/nomad/.travis.yml b/roles/nomad/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/nomad/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/nomad/README.md b/roles/nomad/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/nomad/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/nomad/defaults/main.yml b/roles/nomad/defaults/main.yml new file mode 100644 index 0000000..bd47480 --- /dev/null +++ b/roles/nomad/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for nomad diff --git a/roles/nomad/files/nomad.service b/roles/nomad/files/nomad.service new file mode 100644 index 0000000..ea6d769 --- /dev/null +++ b/roles/nomad/files/nomad.service @@ -0,0 +1,9 @@ +[Unit] +Description="nomad" +[Service] +Restart=always +RestartSec=30 +TimeoutStartSec=1m +ExecStart=/usr/bin/nomad agent -config /etc/nomad/config.hcl +[Install] +WantedBy=multi-user.target diff --git a/roles/nomad/handlers/main.yml b/roles/nomad/handlers/main.yml new file mode 100644 index 0000000..ec1d972 --- /dev/null +++ b/roles/nomad/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for nomad diff --git a/roles/nomad/meta/main.yml b/roles/nomad/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/nomad/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/nomad/tasks/main.yml b/roles/nomad/tasks/main.yml new file mode 100644 index 0000000..161793c --- /dev/null +++ b/roles/nomad/tasks/main.yml @@ -0,0 +1,36 @@ +- name: Install Unzip + apt: + name: unzip + state: present + +- name: Checking if Nomad Binary Exists + stat: + path: /usr/bin/nomad + register: nomad_file + +- name: Download and Extract Nomad binary and move to /usr/bin + unarchive: + src: https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_amd64.zip + dest: /usr/bin + remote_src: yes + when: nomad_file.stat.exists == False + +- name: Create Nomad Configuration Directory + file: + path: /etc/nomad + state: directory + +- name: Render Nomad Configuration Template to /usr/nomad/config.hcl + template: + src: config.hcl.j2 + dest: /etc/nomad/config.hcl + +- name: Copying Nomad Init File + copy: + src: nomad.service + dest: /etc/systemd/system/nomad.service + +- name: Enabling Nomad Systemd Service + systemd: + name: nomad.service + enabled: yes diff --git a/roles/nomad/templates/config.hcl.j2 b/roles/nomad/templates/config.hcl.j2 new file mode 100644 index 0000000..691c58f --- /dev/null +++ b/roles/nomad/templates/config.hcl.j2 @@ -0,0 +1,18 @@ +log_level = "DEBUG" +# name = "" +data_dir = "/opt/nomad" +datacenter = "default" +advertise { + http = "{{ ansible_default_ipv4.address }}" + rpc = "{{ ansible_default_ipv4.address }}" + serf = "{{ ansible_default_ipv4.address }}" +} +client { + enabled = true + # Expecting to have DNS record for nomad server(s) + server_join = { + retry_join = ["{{ ansible_default_ipv4.address }}:4647"] + } + node_class = "linux-64bit" + options = {"driver.raw_exec.enable" = "1"} +} diff --git a/roles/nomad/tests/inventory b/roles/nomad/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/nomad/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/nomad/tests/test.yml b/roles/nomad/tests/test.yml new file mode 100644 index 0000000..77a8d32 --- /dev/null +++ b/roles/nomad/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - nomad diff --git a/roles/nomad/vars/main.yml b/roles/nomad/vars/main.yml new file mode 100644 index 0000000..0f606ff --- /dev/null +++ b/roles/nomad/vars/main.yml @@ -0,0 +1 @@ +nomad_version: "0.11.8"