Skip to content
Snippets Groups Projects
Commit 81bb4361 authored by Arie Peterson's avatar Arie Peterson
Browse files

Add ansible version of bootstrap script

parent e4cf19bd
No related branches found
No related tags found
No related merge requests found
---
- hosts: cluster
roles:
- role: prepare_node
- role: get_control
- role: configure
- role: setup
---
- name: Install local configuration for helmfile
template:
src: "local.yaml.j2"
dest: "{{ configuration_directory }}/values/local.yaml"
become: true
# Substituted automatically, you normally don't need to change this.
ip: "{{ ip_address }}"
# The domain name under which your applications will be found.
domain: "{{ domain }}"
# An email address that will reach someone administrating the cluster.
adminEmail: "{{ admin_email }}"
# A label for the application releases. If you have multiple deployments
# this allows you to distinguish them.
releaseName: "{{ release_name }}"
---
- name: Create some directories
file:
path: "{{ item }}"
state: directory
become: true
with_items:
- "/oas/local/control"
- "/oas/bin"
- name: Generate SSH keys
shell: ssh-keygen -f {{ configuration_directory }}/ssh_key -C "oas-control@${hostname}" -q -N ""
args:
creates: "{{ configuration_directory }}/ssh_key"
become: true
- name: Retrieve new public key
slurp:
src: "{{ configuration_directory }}/ssh_key.pub"
register: ssh_key
become: true
- name: Allow access to node using new key
authorized_key:
key: "{{ ssh_key.content | b64decode }}"
user: "root"
comment: "OpenAppStack control"
become: true
- name: Install python docker module
apt:
name: "python-docker"
become: true
- name: Get control docker image
docker_image:
name: "docker.greenhost.net/openappstack/bootstrap/control"
become: true
- name: Copy shell command to run control shell
copy:
src: "control-shell.sh"
dest: "/oas/bin/control-shell.sh"
mode: "0755"
become: true
configuration_directory: "/oas/config"
---
- name: Install docker apt repo key
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
id: "0x8D81803C0EBFCD88"
become: true
- name: Add docker apt repo
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_facts['lsb']['codename'] }} stable"
become: true
- name: Install docker
apt:
name: "docker-ce=17.03.3~ce-0~ubuntu-xenial"
update_cache: true
become: true
---
- name: Check presence of required variables
debug:
var: ip_address
- name: Create directory for values
file:
path: "{{ configuration_directory }}/values"
state: directory
become: true
- name: Store external ip on the node itself
copy:
content: "{{ ip_address }}"
dest: "{{ configuration_directory }}/ip"
- name: Load kernel bridge module
modprobe:
name: "br_netfilter"
become: true
- name: Process bridged packets with iptables
sysctl:
name: "net.bridge.bridge-nf-call-iptables"
value: "1"
become: true
- name: Allow external access to kubernetes apiserver
iptables:
chain: "INPUT"
protocol: "tcp"
destination_port: 6443
jump: "ACCEPT"
become: true
- name: Save changes to iptables rules
shell: netfilter-persistent save
become: true
- name: Install docker if necessary
import_tasks: "docker.yml"
---
- name: Run setup program in control image
shell: docker run --rm -i \
--hostname=control \
-v /oas:/oas \
-v /oas/local/control:/control/local \
docker.greenhost.net/openappstack/bootstrap/control \
/control/bin/control setup
become: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment