Bugfix variable on Docker install, updated README.md and added LICENSE

This commit is contained in:
Xan Manning 2019-03-10 14:53:52 +00:00
parent 542d3f04ce
commit a6ff65900d
5 changed files with 88 additions and 16 deletions

26
LICENSE Normal file
View File

@ -0,0 +1,26 @@
Copyright 2019 Xan Manning
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,6 +1,7 @@
# k3s
# Ansible Role: k3s
Ansible role for installing k3s as either a standalone server or cluster.
Ansible role for installing [Racher Labs k3s](https://k3s.io/) ("Lightweight
Kubernetes") as either a standalone server or cluster.
## Requirements
@ -10,16 +11,54 @@ This role has been tested on Ansible 2.6.0+ against the following Linux Distribu
- Debian 9
- Ubuntu 18.04 LTS
## Disclaimer
:warning: Not suitable for production use.
Whilst Rancher Labs are awesome, k3s is a fairly new project and not yet a v1.0
release so extreme caution and operational rigor is recommended before using
this role for any serious development.
## Role Variables
### Group Variables
Below are variables that are set against all of the play hosts for environment
consistency.
| Variable | Description | Default Value |
|--------------------------------|--------------------------------------------------------------------------|--------------------------------|
| `k3s_release_version` | Use a specific version of k3s, eg. `v0.1.0`. Specify `false` for latest. | `false` |
| `k3s_release_version` | Use a specific version of k3s, eg. `v0.2.0`. Specify `false` for latest. | `false` |
| `k3s_github_url` | Set the GitHub URL to install k3s from. | https://github.com/rancher/k3s |
| `k3s_install_dir` | Installation directory for k3s. | `/usr/local/bin` |
| `k3s_control_workers` | Are control hosts also workers? | `true` |
| `k3s_ensure_docker_installed ` | Use Docker rather than Containerd? | `false` |
#### Important note about `k3s_release_version`
If you do not set a `k3s_release_version` the latest version of k3s will be
installed. If you are developing against a specific version of k3s you must
ensure this is set in your Ansible configuration, eg:
```yaml
k3s_release_version: v0.2.0
```
### Host Variables
Below are variables that are set against specific hosts in your inventory.
| Variable | Description | Default Value |
|--------------------|--------------------------------------------------------|---------------|
| `k3s_control_node` | Define the host as a control plane node, (True/False). | `false` |
#### Important note about `k3s_control_node`
Currently only one host can be defined as a control node, if multiple hosts are
set to true the play will fail.
If you do not set a host as a control node, the role will automatically delegate
the first play host as a control node.
## Dependencies
@ -32,7 +71,7 @@ Example playbook:
```yaml
- hosts: k3s_nodes
roles:
- { role: xanmanning.k3s, k3s_control_workers: false }
- { role: xanmanning.k3s, k3s_release_version: v0.2.0 }
```
## License

View File

@ -1,15 +1,5 @@
---
- name: Ensure k3s is symlinked into the installation destinations
file:
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
dest: "{{ k3s_install_dir }}/{{ item }}"
state: link
loop:
- k3s
- kubectl
- crictl
- name: Ensure k3s service unit file is present on control plane
template:
src: k3s.service.j2
@ -20,6 +10,18 @@
- meta: flush_handlers
- name: Ensure k3s is symlinked into the installation destinations
file:
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
dest: "{{ k3s_install_dir }}/{{ item }}"
state: link
notify:
- restart k3s
loop:
- k3s
- kubectl
- crictl
- name: Ensure k3s control plane is started
service:
name: k3s

View File

@ -3,11 +3,11 @@
- include_tasks: preconfigure-k3s.yml
- include_tasks: install-docker-prerequisites-{{ ansible_os_family|lower }}.yml
when: k3s_ensure_docker_installed
and ((k3s_control_workers and k3_control_node)
and ((k3s_control_workers and k3s_control_node)
or (not k3s_control_workers and not k3s_control_node))
- include_tasks: install-docker.yml
when: k3s_ensure_docker_installed
and ((k3s_control_workers and k3_control_node)
and ((k3s_control_workers and k3s_control_node)
or (not k3s_control_workers and not k3s_control_node))
- include_tasks: get-version.yml
when: k3s_release_version is not defined or not k3s_release_version

View File

@ -0,0 +1,5 @@
---
- hosts: node1
become: true
roles:
- ansible-role-k3s