mirror of
https://github.com/wahyd4/playbook.git
synced 2026-08-09 04:35:58 +10:00
Add playbook
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
FROM busybox:latest
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY callback_plugins /workspace/callback_plugins
|
||||
COPY docker-playbook /workspace/docker-playbook
|
||||
COPY etcd-playbook /workspace/etcd-playbook
|
||||
COPY kubernetes-playbook /workspace/kubernetes-playbook
|
||||
COPY registry-playbook /workspace/registry-playbook
|
||||
COPY components_order.conf /workspace
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,2 +1,4 @@
|
||||
# playbook
|
||||
playbook (binary files removed)
|
||||
[](https://travis-ci.org/wise2c-devops/playbook)
|
||||
|
||||
playbook for pagoda format
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
# (C) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
import httplib
|
||||
from collections import MutableMapping
|
||||
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
|
||||
|
||||
# NOTE: in Ansible 1.2 or later general logging is available without
|
||||
# this plugin, just set ANSIBLE_LOG_PATH as an environment variable
|
||||
# or log_path in the DEFAULTS section of your ansible configuration
|
||||
# file. This callback is an example of per hosts logging for those
|
||||
# that want it.
|
||||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
"""
|
||||
logs playbook results, per host, in /var/log/ansible/hosts
|
||||
"""
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'notification'
|
||||
CALLBACK_NAME = 'log_plays'
|
||||
CALLBACK_NEEDS_WHITELIST = True
|
||||
|
||||
TIME_FORMAT = "%b %d %Y %H:%M:%S"
|
||||
MSG_FORMAT = "%(now)s - %(category)s - %(data)s\n\n"
|
||||
|
||||
def __init__(self):
|
||||
super(CallbackModule, self).__init__()
|
||||
|
||||
self.task = dict()
|
||||
self.data = dict()
|
||||
self.stage = ""
|
||||
|
||||
def log(self, host, category, data):
|
||||
state = "processing"
|
||||
if isinstance(data, MutableMapping):
|
||||
if "state" in data.keys():
|
||||
state = data["state"]
|
||||
|
||||
if "changed" in data.keys():
|
||||
self.data["changed"] = data["changed"]
|
||||
else:
|
||||
self.data["changed"] = False
|
||||
|
||||
if "msg" in data.keys():
|
||||
self.data["msg"] = data["msg"]
|
||||
else:
|
||||
self.data["msg"] = ""
|
||||
|
||||
now = time.strftime(self.TIME_FORMAT, time.localtime())
|
||||
self.task["state"] = category
|
||||
|
||||
h1 = httplib.HTTPConnection('127.0.0.1:8080')
|
||||
h1.request(
|
||||
"POST",
|
||||
"/v1/notify",
|
||||
json.dumps(
|
||||
dict(
|
||||
time=now,
|
||||
data=self.data,
|
||||
task=self.task,
|
||||
host=host,
|
||||
state=state,
|
||||
stage=self.stage
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def runner_on_failed(self, host, res, ignore_errors=False):
|
||||
self.log(host, 'failed', res)
|
||||
|
||||
def runner_on_ok(self, host, res):
|
||||
self.log(host, 'ok', res)
|
||||
|
||||
def runner_on_skipped(self, host, item=None):
|
||||
self.log(host, 'skipped', '...')
|
||||
|
||||
def runner_on_unreachable(self, host, res):
|
||||
self.log(host, 'unreachable', res)
|
||||
|
||||
def runner_on_async_failed(self, host, res, jid):
|
||||
self.log(host, 'ASYNC_FAILED', res)
|
||||
|
||||
def v2_playbook_on_start(self, playbook):
|
||||
name, suffix = os.path.basename(os.path.dirname(playbook._basedir)).split('-')
|
||||
self.stage = name
|
||||
|
||||
def playbook_on_import_for_host(self, host, imported_file):
|
||||
self.log(host, 'IMPORTED', imported_file)
|
||||
|
||||
def playbook_on_not_import_for_host(self, host, missing_file):
|
||||
self.log(host, 'NOTIMPORTED', missing_file)
|
||||
|
||||
def playbook_on_task_start(self, name, is_conditional):
|
||||
self.task['name'] = name
|
||||
|
||||
def playbook_on_stats(self, stats):
|
||||
state = ""
|
||||
if len(stats.failures) > 0 or len(stats.dark) > 0:
|
||||
state = "failed"
|
||||
else:
|
||||
state = "ok"
|
||||
self.task['name'] = "ending"
|
||||
self.log("all", state, dict(state=state))
|
||||
@@ -0,0 +1,6 @@
|
||||
docker
|
||||
registry
|
||||
loadbalancer
|
||||
etcd
|
||||
mysql
|
||||
kubernetes
|
||||
@@ -0,0 +1,33 @@
|
||||
version: '2'
|
||||
services:
|
||||
deploy:
|
||||
image: wise2c/pagoda:v0.4.1
|
||||
restart: always
|
||||
entrypoint: sh
|
||||
command:
|
||||
- -c
|
||||
- "/root/pagoda -logtostderr -v 4 -w /workspace"
|
||||
ports:
|
||||
- 88:80
|
||||
- 8088:8080
|
||||
volumes:
|
||||
- /root/.ssh:/root/.ssh
|
||||
- $PWD/deploy:/deploy
|
||||
volumes_from:
|
||||
- playbook
|
||||
ui:
|
||||
image: wise2c/deploy-ui:v0.4
|
||||
restart: always
|
||||
network_mode: "service:deploy"
|
||||
playbook:
|
||||
image: wise2c/playbook:v0.4
|
||||
volumes:
|
||||
- playbook:/workspace
|
||||
yum-repo:
|
||||
image: wise2c/yum-repo:7.4
|
||||
ports:
|
||||
- 2009:2009
|
||||
restart: always
|
||||
volumes:
|
||||
playbook:
|
||||
external: false
|
||||
@@ -0,0 +1,5 @@
|
||||
[defaults]
|
||||
inventory=hosts
|
||||
callback_plugins = ../../callback_plugins
|
||||
callback_whitelist = log_back
|
||||
retry_files_enabled = false
|
||||
@@ -0,0 +1,130 @@
|
||||
- name: init host
|
||||
hosts: hosts
|
||||
user: root
|
||||
any_errors_fatal: true
|
||||
vars:
|
||||
path: /var/tmp/wise2c/docker
|
||||
tasks:
|
||||
- name: set hostname
|
||||
hostname:
|
||||
name: '{{ hostname }}'
|
||||
when: format_hostname
|
||||
|
||||
- name: get seed ip
|
||||
shell:
|
||||
echo $SSH_CONNECTION | cut -d " " -f 1
|
||||
register: ip
|
||||
|
||||
- name: add seed to /etc/hosts
|
||||
blockinfile:
|
||||
path: /etc/hosts
|
||||
block: '{{ ip.stdout }} {{ wise2c_seed_host }}'
|
||||
marker: '# {mark} WISE2C DEPLOY MANAGED BLOCK {{ wise2c_seed_host }}'
|
||||
|
||||
- name: add to /etc/hosts
|
||||
blockinfile:
|
||||
path: /etc/hosts
|
||||
block: '{{ item.key }} {{ item.value.hostname }}'
|
||||
marker: "# {mark} WISE2C DEPLOY MANAGED BLOCK {{ item.key }}"
|
||||
with_dict: "{{ hostvars }}"
|
||||
|
||||
- name: disabled selinux
|
||||
selinux:
|
||||
state: disabled
|
||||
|
||||
- name: start firewalld
|
||||
systemd:
|
||||
name: firewalld
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: config firewalld
|
||||
shell: |
|
||||
firewall-cmd --set-default-zone=trusted
|
||||
firewall-cmd --complete-reload
|
||||
|
||||
- name: distribute wise2c repo
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/wise2c.repo.j2', dest: '/etc/yum.repos.d/wise2c.repo' }
|
||||
|
||||
- name: install docker
|
||||
yum:
|
||||
disablerepo: '*'
|
||||
enablerepo: wise2c
|
||||
update_cache: true
|
||||
state: present
|
||||
name: '{{ item }}'
|
||||
with_items:
|
||||
- rsync
|
||||
- jq
|
||||
- chrony
|
||||
- docker
|
||||
- python-docker-py
|
||||
- docker-compose
|
||||
|
||||
- name: distribute chrony server config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/chrony-server.conf.j2', dest: '/etc/chrony.conf' }
|
||||
when: inventory_hostname == ansible_play_batch[0]
|
||||
|
||||
- name: distribute chrony client config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/chrony-client.conf.j2', dest: '/etc/chrony.conf' }
|
||||
when: inventory_hostname != ansible_play_batch[0]
|
||||
|
||||
- name: start chrony
|
||||
systemd:
|
||||
name: chronyd
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: check docker
|
||||
script: scripts/check_docker.sh {{ registry }}
|
||||
register: check_output
|
||||
|
||||
- block:
|
||||
- name: clear docker config
|
||||
copy:
|
||||
content: ''
|
||||
dest: '{{ item }}'
|
||||
with_items:
|
||||
- /etc/sysconfig/docker
|
||||
- /etc/sysconfig/docker-storage
|
||||
- /etc/sysconfig/docker-storage-setup
|
||||
- /etc/sysconfig/docker-network
|
||||
|
||||
- name: distribute docker config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/daemon.json.j2', dest: '/etc/docker/daemon.json' }
|
||||
|
||||
- name: reload & restart docker
|
||||
systemd:
|
||||
name: docker
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: set sysctl
|
||||
sysctl:
|
||||
name: '{{ item }}'
|
||||
value: 1
|
||||
state: present
|
||||
reload: true
|
||||
with_items:
|
||||
- net.ipv4.ip_forward
|
||||
- net.bridge.bridge-nf-call-iptables
|
||||
- net.bridge.bridge-nf-call-ip6tables
|
||||
when: check_output.stdout != 'true'
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"variable": "format_hostname",
|
||||
"label": "format host name",
|
||||
"description": "format host name if you check this",
|
||||
"type": "bool",
|
||||
"default": "false",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
- name: clean docker
|
||||
hosts: hosts
|
||||
user: root
|
||||
tasks:
|
||||
# - name: install docker
|
||||
# yum:
|
||||
# disablerepo: '*'
|
||||
# enablerepo: wise2c
|
||||
# state: absent
|
||||
# name: '{{ item }}'
|
||||
# with_items:
|
||||
# - rsync
|
||||
# - jq
|
||||
# - chrony
|
||||
# - docker
|
||||
# - python-docker-py
|
||||
# - docker-compose
|
||||
@@ -0,0 +1,8 @@
|
||||
#! /bin/bash
|
||||
|
||||
name=`curl -sS --unix-socket /var/run/docker.sock http:/v1.24/info | jq -r '.RegistryConfig.IndexConfigs."'$1'".Name'`
|
||||
if [ "${name}" == "$1" ]; then
|
||||
echo -n true
|
||||
else
|
||||
echo -n false
|
||||
fi
|
||||
@@ -0,0 +1,2 @@
|
||||
# Use servers .
|
||||
server {{ ansible_play_batch[0] }} iburst
|
||||
@@ -0,0 +1,21 @@
|
||||
# Use servers .
|
||||
server {{ ansible_play_batch[0] }} iburst
|
||||
|
||||
# Record the rate at which the system clock gains/losses time.
|
||||
driftfile /var/lib/chrony/drift
|
||||
|
||||
# Allow the system clock to be stepped in the first three updates
|
||||
# if its offset is larger than 1 second.
|
||||
makestep 1.0 3
|
||||
|
||||
# Enable kernel synchronization of the real-time clock (RTC).
|
||||
rtcsync
|
||||
|
||||
# Allow NTP client access from local network.
|
||||
allow
|
||||
|
||||
# Serve time even if not synchronized to a time source.
|
||||
local stratum 10
|
||||
|
||||
# Specify directory for log files.
|
||||
logdir /var/log/chrony
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"exec-opt": [
|
||||
"native.cgroupdriver=systemd"
|
||||
],
|
||||
"log-driver": "json-file",
|
||||
"log-opts": {
|
||||
"max-size": "100m",
|
||||
"max-file": "5"
|
||||
},
|
||||
"insecure-registries": [
|
||||
"{{ registry }}"
|
||||
],
|
||||
"storage-driver": "overlay2"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[wise2c]
|
||||
name=wise2c
|
||||
baseurl=http://{{ wise2c_seed_host }}:2009/
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
@@ -0,0 +1,4 @@
|
||||
[hosts]
|
||||
{{ range $v := .AllHosts -}}
|
||||
{{ $v.IP }} hostname={{ $v.HostName }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,3 @@
|
||||
wise2c_seed_host: wise2c-seed
|
||||
registry: {{ .registry.Inherent.endpoint }}
|
||||
format_hostname: {{ .docker.Property.format_hostname }}
|
||||
@@ -0,0 +1,5 @@
|
||||
[defaults]
|
||||
inventory=hosts
|
||||
callback_plugins = ../../callback_plugins
|
||||
callback_whitelist = log_back
|
||||
retry_files_enabled = false
|
||||
@@ -0,0 +1,16 @@
|
||||
command:
|
||||
- etcd
|
||||
- |
|
||||
{% for host in ansible_play_batch -%}
|
||||
{% if host == inventory_hostname -%}
|
||||
--name etcd{{ loop.index0 }}
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
- --data-dir /var/lib/etcd
|
||||
- --advertise-client-urls http://{{ inventory_hostname }}:2379
|
||||
- --listen-client-urls http://{{ inventory_hostname }}:2379
|
||||
- --listen-peer-urls http://{{ inventory_hostname }}:2380
|
||||
- --initial-cluster-token etcd-cluster
|
||||
- --initial-advertise-peer-urls http://{{ inventory_hostname }}:2380
|
||||
- --initial-cluster {% for host in play_hosts %}etcd{{ loop.index0 }}=http://{{ host }}:2380{% if not loop.last %},{% endif %}{% endfor %}
|
||||
- --initial-cluster-state new
|
||||
@@ -0,0 +1,3 @@
|
||||
endpoint: {{ range $i, $v := .Hosts.self -}}
|
||||
http://{{ $v.IP }}:2379{{if notLast $i $.Hosts.self}},{{end}}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,13 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
path=`dirname $0`
|
||||
|
||||
image=gcr.io/google_containers/etcd-amd64:${1}
|
||||
echo "" >> ${path}/group_vars/etcd.yml
|
||||
echo "image: ${image}" >> ${path}/group_vars/etcd.yml
|
||||
|
||||
docker pull ${image}
|
||||
docker save ${image} > ${path}/file/etcd.tar
|
||||
bzip2 -z --best ${path}/file/etcd.tar
|
||||
@@ -0,0 +1,36 @@
|
||||
- name: install etcd
|
||||
hosts: etcd
|
||||
user: root
|
||||
vars:
|
||||
path: /var/tmp/wise2c/etcd
|
||||
tasks:
|
||||
- name: make etcd dir
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: directory
|
||||
mode: 0755
|
||||
with_items:
|
||||
- '{{ path }}'
|
||||
|
||||
- name: copy etcd image
|
||||
copy:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'file/etcd.tar.bz2', dest: '{{ path }}' }
|
||||
|
||||
- name: load etcd image
|
||||
docker_image:
|
||||
load_path: '{{ path }}/etcd.tar.bz2'
|
||||
name: '{{ image }}'
|
||||
timeout: 600
|
||||
|
||||
- name: run etcd
|
||||
docker_container:
|
||||
name: etcd
|
||||
network_mode: host
|
||||
restart_policy: unless-stopped
|
||||
image: '{{ image }}'
|
||||
command: '{{ command }}'
|
||||
volumes:
|
||||
- /data/wisecloud/etcd:/var/lib/etcd
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"variable": "self",
|
||||
"label": "etcd hosts",
|
||||
"description": "hosts for setup etcd",
|
||||
"type": "host",
|
||||
"default": "",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
- name: clean etcd
|
||||
hosts: etcd
|
||||
user: root
|
||||
tasks:
|
||||
- name: stop & rm old etcd container
|
||||
docker_container:
|
||||
name: etcd
|
||||
state: absent
|
||||
|
||||
- name: clean etcd directory
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- /data/wisecloud/etcd
|
||||
@@ -0,0 +1,4 @@
|
||||
[etcd]
|
||||
{{ range $v := .etcd.Hosts.self -}}
|
||||
{{ $v.IP }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,18 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
path=`dirname $0`
|
||||
|
||||
for dir in `ls ${path}`
|
||||
do
|
||||
if [[ ${dir} =~ -playbook$ ]]; then
|
||||
for version in `ls ${path}/${dir}`
|
||||
do
|
||||
echo ${version}
|
||||
if [ -f ${path}/${dir}/${version}/init.sh ]; then
|
||||
bash ${path}/${dir}/${version}/init.sh ${version}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,5 @@
|
||||
[defaults]
|
||||
inventory=hosts
|
||||
callback_plugins = ../../callback_plugins
|
||||
callback_whitelist = log_back
|
||||
retry_files_enabled = false
|
||||
@@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC/zCCAeegAwIBAgIIWMwr1Sadq2EwDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE
|
||||
AxMKa3ViZXJuZXRlczAeFw0xNzA3MDQwMjMzMzdaFw0xODA3MDQwNDUxNTVaMEEx
|
||||
FzAVBgNVBAoTDnN5c3RlbTptYXN0ZXJzMSYwJAYDVQQDEx1rdWJlLWFwaXNlcnZl
|
||||
ci1rdWJlbGV0LWNsaWVudDCCASIwDQYJKoZIh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TxnhmBK
|
||||
+LC4jb31PgIQkoQkRHmAsKjiKag8bRXgq9hYqZfhKoDT/735AqYg5ZJ3cVeFEJwA
|
||||
99MPHV0/2c96Pb/ZGUIaPd7alNNGdcuDI9uDLoMI71We+mJuMpVaCn/0/Csqhib5
|
||||
KS4kGooPP2Ecez7bo1eMhKCtAoGAUvfgHIBI2KjgH+B6tY7C/0bFyRrbHl/mxq59
|
||||
MVc/MqDNTSyx7boNxxRvL7UTbbzCjF+Z6KL04tF/lGd/UlwdaKdU1fXRu41/KNlI
|
||||
TKE+gW08jTHqy4orHrFN+2sRdAmWvmuZxz4WFxZT1+EmgmOgzWvSyjw9KGVIckKy
|
||||
otloCaUCgYEA3W6YvOH1eEecZc+wjJ1ejmNUc3Ugc1uioyyQeGxTBp8XL8nz/dxy
|
||||
QXyLssRIhCYjTsCTa4MtA2HyHXP/1d0ZrA5cgJpifvbhmSuMgn/IRMJqgvwA5Usr
|
||||
AMQz0JC4UPrjh89C2VkpkYqsAVj/2JJi+xugU5ReM46XLyY8A4XXthE=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl
|
||||
cm5ldGVzMB4XDTE3MDcwNDAyMzMzN1oXDTI3MDcwMjAyMzMzN1owFTETMBEGA1UE
|
||||
AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANDj
|
||||
I5qX0fFgrlIK9YhBjHuIpTXqZldyveevNhdwlOYDiCKpGwPdaxC9++foh88Xerv/
|
||||
QvO5EflPu8IhEmoM+wu7a2hdVPPOcPxE9Fn0N6O0LXtgpjkAgALXQklKx1tk6Fja
|
||||
M4BhUaJD9zKSP6PVSjPRDTs+4yJnWGJQYaAN3pkIF9mFx2+GWoo07F4yDoRUtsqv
|
||||
+kBISIyWai+lOjofZS0cIoxgNwUMxg4OGcL3F1Yxkf36o4qtO7H8FPJFAvnKHFgp
|
||||
IpYdfiporRykw4e0vSSYmpoCzBgzg/po8K7Tw/jSGPUR4m91IYBTJm1ZDBAMbnLE
|
||||
tPmOOqze2az0YSHcekECAwEAAaMjMCEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB
|
||||
/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAGwZth8zU7AAbZxD1lzBvlSFn9yh
|
||||
W8I6xYLBBAtUT0anvrqXV2XttW7QtaEDIFOQrohjUwkWZyRm9iKTZZCh2Pw1pNkf
|
||||
YQzsg0weEb++YJSVrpzMDl/P4V/lZsv1rFanma+wu0wdmeJkVP8mfqtbjdKlioMa
|
||||
azrmkiZm37NAdqbF5/kAGYNb/oHJukx9MR9oIw3aP1zDREGC42soj5xRujiDzMKH
|
||||
vdY8IjU1SArEd3HxrLbrrEMqs4baiEx9Rp4y3hbrvKGFPS+x5IU3nPKUJTbCNw8S
|
||||
8ImrvUFpY1VOR0rDjHs+Fh8vDp7LoTxA4x8Ryy0NlsXnBjJSFaecVazDQ8Q=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEA0OMjmpfR8WCuUgr1iEGMe4ilNepmV3K95682F3CU5gOIIqkb
|
||||
A91rEL375+iHzxd6u/9C87kR+U+7wiESagz7C7traF1U885w/ET0WfQ3o7Qte2Cm
|
||||
OQCAAtdCSUrHW2ToWNozgGFRokP3MpI/o9VKM9ENOz7jImdYYlBhoA3emQgX2YXH
|
||||
b4ZaijTsXjIOhFS2yq/6QEhIjJZqL6U6Oh9lLRwijGA3BQzGDg4ZwvcXVjGR/fqj
|
||||
iq07sfwU8kUC+cocWCkilh1+KmitHKTDh7S9JJiamgLMGDOD+mjwrtPD+NIY9RHi
|
||||
b3UhgFMmbVkMEAxucsS0+Y46rN7ZrPRhIdx6QQIDAQABA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V4
|
||||
JYGI3NxXvrCo0530+3q+z/z4yb6MGEK5DP/JT2/69Mtego2XG6p2AHqnyCEjWsEt
|
||||
ip7cswKBgCA7ANxZHhIFebHFNm0HUQzGFN9WpfJTNhn/veNqzvegS1Z1BvXwxXxO
|
||||
urYfu8gONyJXrrOKf2vwBgRxwCbiZ2fFACPx/SQrMliNRuV6MvclfuIXxInvX6R3
|
||||
VqKBQnmO8xg/GRIem/8BWBUihp4m6auA8GYOpd6wl+6fz9i7+Su7
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,42 @@
|
||||
# Create the clusterrole and clusterrolebinding:
|
||||
# $ kubectl create -f kube-flannel-rbac.yml
|
||||
# Create the pod using the same namespace used by the flannel serviceaccount:
|
||||
# $ kubectl create --namespace kube-system -f kube-flannel.yml
|
||||
---
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: flannel
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- nodes
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- nodes/status
|
||||
verbs:
|
||||
- patch
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: flannel
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: flannel
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: flannel
|
||||
namespace: kube-system
|
||||
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpgIBAAKCAQEA4+Td6C+8Wp9t99S6sipRcNCgUxm9+c98VFCfoV/3t9AFw3CZ
|
||||
aFRZpWchH73Tk1laKGG3sbH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
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,5 @@
|
||||
endpoint: {{ if eq (print .Property.endpoint) "" -}}
|
||||
{{ (index .Hosts.master 0).IP }}:6443
|
||||
{{- else -}}
|
||||
{{ .Property.endpoint }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,84 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
path=`dirname $0`
|
||||
|
||||
kubernetes_repo="gcr.io/google_containers"
|
||||
kubernetes_version=`docker run -it --rm \
|
||||
-e KUBERNETES_VERSION=${1} \
|
||||
-e KUBERNETES_COMPONENT=kube-apiserver \
|
||||
ymian/kube-version:1.8`
|
||||
dns_version=`docker run -it --rm \
|
||||
-e KUBERNETES_VERSION=${1} \
|
||||
-e KUBERNETES_COMPONENT=kube-dns \
|
||||
ymian/kube-version:1.8`
|
||||
pause_version="3.0"
|
||||
echo "" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "kubernetes_repo: ${kubernetes_repo}" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "kubernetes_version: ${kubernetes_version}" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "dns_version: ${dns_version}" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "pause_version: ${pause_version}" >> ${path}/yat/all.yml.gotmpl
|
||||
|
||||
flannel_repo="quay.io/coreos"
|
||||
flannel_version="v0.10.0"
|
||||
echo "flannel_repo: ${flannel_repo}" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "flannel_version: ${flannel_version}-amd64" >> ${path}/yat/all.yml.gotmpl
|
||||
|
||||
curl -sS https://raw.githubusercontent.com/coreos/flannel/${flannel_version}/Documentation/kube-flannel.yml \
|
||||
| sed -e "s,quay.io/coreos,{{ registry_endpoint }}/{{ registry_project }},g" > ${path}/template/kube-flannel.yml.j2
|
||||
|
||||
dashboard_repo="k8s.gcr.io"
|
||||
dashboard_version="v1.8.3"
|
||||
echo "dashboard_repo: ${dashboard_repo}" >> ${path}/yat/all.yml.gotmpl
|
||||
echo "dashboard_version: ${dashboard_version}" >> ${path}/yat/all.yml.gotmpl
|
||||
|
||||
curl -sS https://raw.githubusercontent.com/kubernetes/dashboard/${dashboard_version}/src/deploy/recommended/kubernetes-dashboard.yaml \
|
||||
| sed -e "s,k8s.gcr.io,{{ registry_endpoint }}/{{ registry_project }},g" > ${path}/template/kubernetes-dashboard.yml.j2
|
||||
|
||||
curl -L -o ${path}/file/cni-plugins-amd64-v0.6.0.tgz https://github.com/containernetworking/plugins/releases/download/v0.6.0/cni-plugins-amd64-v0.6.0.tgz
|
||||
|
||||
echo "=== pulling kubernetes images ==="
|
||||
docker pull ${kubernetes_repo}/kube-apiserver-amd64:${kubernetes_version}
|
||||
docker pull ${kubernetes_repo}/kube-controller-manager-amd64:${kubernetes_version}
|
||||
docker pull ${kubernetes_repo}/kube-scheduler-amd64:${kubernetes_version}
|
||||
docker pull ${kubernetes_repo}/kube-proxy-amd64:${kubernetes_version}
|
||||
docker pull ${kubernetes_repo}/pause-amd64:${pause_version}
|
||||
docker pull ${kubernetes_repo}/k8s-dns-sidecar-amd64:${dns_version}
|
||||
docker pull ${kubernetes_repo}/k8s-dns-kube-dns-amd64:${dns_version}
|
||||
docker pull ${kubernetes_repo}/k8s-dns-dnsmasq-nanny-amd64:${dns_version}
|
||||
echo "=== pull kubernetes images success ==="
|
||||
echo "=== saving kubernetes images ==="
|
||||
mkdir -p ${path}/file
|
||||
docker save ${kubernetes_repo}/kube-apiserver-amd64:${kubernetes_version} \
|
||||
${kubernetes_repo}/kube-controller-manager-amd64:${kubernetes_version} \
|
||||
${kubernetes_repo}/kube-scheduler-amd64:${kubernetes_version} \
|
||||
${kubernetes_repo}/kube-proxy-amd64:${kubernetes_version} \
|
||||
${kubernetes_repo}/pause-amd64:${pause_version} \
|
||||
${kubernetes_repo}/k8s-dns-sidecar-amd64:${dns_version} \
|
||||
${kubernetes_repo}/k8s-dns-kube-dns-amd64:${dns_version} \
|
||||
${kubernetes_repo}/k8s-dns-dnsmasq-nanny-amd64:${dns_version} \
|
||||
> ${path}/file/k8s.tar
|
||||
rm ${path}/file/k8s.tar.bz2 -f
|
||||
bzip2 -z --best ${path}/file/k8s.tar
|
||||
echo "=== save kubernetes images success ==="
|
||||
|
||||
echo "=== pulling flannel image ==="
|
||||
docker pull ${flannel_repo}/flannel:${flannel_version}-amd64
|
||||
echo "=== pull flannel image success ==="
|
||||
echo "=== saving flannel image ==="
|
||||
docker save ${flannel_repo}/flannel:${flannel_version}-amd64 \
|
||||
> ${path}/file/flannel.tar
|
||||
rm ${path}/file/flannel.tar.bz2 -f
|
||||
bzip2 -z --best ${path}/file/flannel.tar
|
||||
echo "=== save flannel image success ==="
|
||||
|
||||
echo "=== pulling dashboard image ==="
|
||||
docker pull ${dashboard_repo}/kubernetes-dashboard-amd64:${dashboard_version}
|
||||
echo "=== pull dashboard image success ==="
|
||||
echo "=== saving dashboard image ==="
|
||||
docker save ${dashboard_repo}/kubernetes-dashboard-amd64:${dashboard_version} \
|
||||
> ${path}/file/dashboard.tar
|
||||
rm ${path}/file/dashboard.tar.bz2 -f
|
||||
bzip2 -z --best ${path}/file/dashboard.tar
|
||||
echo "=== save dashboard image success ==="
|
||||
@@ -0,0 +1,79 @@
|
||||
- name: install kubernetes package
|
||||
hosts: all
|
||||
user: root
|
||||
vars:
|
||||
path: /var/tmp/wise2c/kubernetes
|
||||
tasks:
|
||||
- name: make k8s master dir
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: directory
|
||||
mode: 0755
|
||||
with_items:
|
||||
- /etc/kubernetes/pki
|
||||
- '{{ path }}'
|
||||
- $HOME/.kube
|
||||
|
||||
- name: check kubernetes
|
||||
script: scripts/check_kubelet.sh
|
||||
register: check_output
|
||||
|
||||
- name: remove swapfile from /etc/fstab
|
||||
mount:
|
||||
name: swap
|
||||
fstype: swap
|
||||
state: absent
|
||||
|
||||
- name: disable swap
|
||||
command: swapoff -a
|
||||
|
||||
- block:
|
||||
- name: install kubernetes components
|
||||
yum:
|
||||
disablerepo: '*'
|
||||
enablerepo: wise2c
|
||||
update_cache: true
|
||||
state: present
|
||||
name: '{{ item }}'
|
||||
with_items:
|
||||
- kubernetes-cni-0.5.1
|
||||
- kubectl-{{ kubernetes_version[1:] }}
|
||||
- kubelet-{{ kubernetes_version[1:] }}
|
||||
- kubeadm-{{ kubernetes_version[1:] }}
|
||||
|
||||
- name: unarchive cni
|
||||
unarchive:
|
||||
src: file/cni-plugins-amd64-v0.6.0.tgz
|
||||
dest: /opt/cni/bin
|
||||
|
||||
- name: distribute kubelet config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/kubelet.conf.j2', dest: '/etc/systemd/system/kubelet.service.d/wise2c-kubelet.conf' }
|
||||
|
||||
- name: reload & enable kubelet
|
||||
systemd:
|
||||
name: kubelet
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
|
||||
- name: set sysctl
|
||||
sysctl:
|
||||
name: '{{ item }}'
|
||||
value: 1
|
||||
state: present
|
||||
reload: true
|
||||
with_items:
|
||||
- net.bridge.bridge-nf-call-iptables
|
||||
- net.bridge.bridge-nf-call-ip6tables
|
||||
|
||||
- name: setup master
|
||||
include_tasks: master.ansible
|
||||
when: role == 'master'
|
||||
|
||||
- name: setup node
|
||||
include_tasks: node.ansible
|
||||
when: role == 'node'
|
||||
when: check_output.stdout != 'true'
|
||||
@@ -0,0 +1,111 @@
|
||||
- name: copy k8s images
|
||||
copy:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'file/k8s.tar.bz2', dest: '{{ path }}' }
|
||||
- { src: 'file/flannel.tar.bz2', dest: '{{ path }}' }
|
||||
- { src: 'file/dashboard.tar.bz2', dest: '{{ path }}' }
|
||||
- { src: 'file/kube-flannel-rbac.yml', dest: '{{ path }}' }
|
||||
run_once: true
|
||||
|
||||
- name: load k8s images
|
||||
docker_image:
|
||||
load_path: '{{ path }}/{{ item }}'
|
||||
name: k8s
|
||||
timeout: 600
|
||||
with_items:
|
||||
- k8s.tar.bz2
|
||||
- flannel.tar.bz2
|
||||
- dashboard.tar.bz2
|
||||
run_once: true
|
||||
|
||||
- name: docker login
|
||||
docker_login:
|
||||
registry: '{{ registry_endpoint }}'
|
||||
username: '{{ registry_user }}'
|
||||
password: '{{ registry_password }}'
|
||||
reauthorize: true
|
||||
run_once: true
|
||||
|
||||
- name: tag images
|
||||
docker_image:
|
||||
name: '{{ item.repo }}/{{ item.name }}'
|
||||
repository: '{{ registry_endpoint }}/{{ registry_project }}/{{ item.name }}'
|
||||
tag: '{{ item.tag }}'
|
||||
with_items:
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-controller-manager-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-apiserver-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-scheduler-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-proxy-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-sidecar-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-kube-dns-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-dnsmasq-nanny-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'pause-amd64', tag: '{{ pause_version }}' }
|
||||
- { repo: '{{ flannel_repo }}', name: 'flannel', tag: '{{ flannel_version }}' }
|
||||
- { repo: '{{ dashboard_repo }}', name: 'kubernetes-dashboard-amd64', tag: '{{ dashboard_version }}' }
|
||||
run_once: true
|
||||
|
||||
- name: push images
|
||||
docker_image:
|
||||
name: '{{ registry_endpoint }}/{{ registry_project }}/{{ item.name }}'
|
||||
tag: '{{ item.tag }}'
|
||||
push: true
|
||||
state: present
|
||||
with_items:
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-controller-manager-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-apiserver-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-scheduler-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'kube-proxy-amd64', tag: '{{ kubernetes_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-sidecar-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-kube-dns-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-dnsmasq-nanny-amd64', tag: '{{ dns_version }}' }
|
||||
- { repo: '{{ kubernetes_repo }}', name: 'pause-amd64', tag: '{{ pause_version }}' }
|
||||
- { repo: '{{ flannel_repo }}', name: 'flannel', tag: '{{ flannel_version }}' }
|
||||
- { repo: '{{ dashboard_repo }}', name: 'kubernetes-dashboard-amd64', tag: '{{ dashboard_version }}' }
|
||||
run_once: true
|
||||
|
||||
- name: generate kubeadm config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/kubeadm.conf.j2', dest: '{{ path }}/kubeadm.conf' }
|
||||
- { src: 'template/kube-flannel.yml.j2', dest: '{{ path }}/kube-flannel.yml' }
|
||||
- { src: 'template/kubernetes-dashboard.yml.j2', dest: '{{ path }}/kubernetes-dashboard.yml' }
|
||||
|
||||
- name: copy crt & key
|
||||
copy:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'file/ca.key', dest: '/etc/kubernetes/pki' }
|
||||
- { src: 'file/ca.crt', dest: '/etc/kubernetes/pki' }
|
||||
- { src: 'file/sa.key', dest: '/etc/kubernetes/pki' }
|
||||
- { src: 'file/sa.pub', dest: '/etc/kubernetes/pki' }
|
||||
- { src: 'file/apiserver-kubelet-client.key', dest: '/etc/kubernetes/pki' }
|
||||
- { src: 'file/apiserver-kubelet-client.crt', dest: '/etc/kubernetes/pki' }
|
||||
|
||||
- name: setup
|
||||
shell: |
|
||||
kubeadm init --config {{ path }}/kubeadm.conf
|
||||
|
||||
- name: fetch admin.conf
|
||||
fetch:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
flat: true
|
||||
with_items:
|
||||
- { src: '/etc/kubernetes/admin.conf', dest: 'file/admin.conf' }
|
||||
run_once: true
|
||||
|
||||
- name: config kubectl
|
||||
shell: |
|
||||
cp /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||
chown $(id -u):$(id -g) $HOME/.kube/config
|
||||
|
||||
- name: apply addons
|
||||
shell: |
|
||||
kubectl apply -f {{ path }}/kube-flannel.yml
|
||||
kubectl apply -f {{ path }}/kubernetes-dashboard.yml
|
||||
run_once: true
|
||||
@@ -0,0 +1,18 @@
|
||||
- name: copy k8s admin.conf
|
||||
copy:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'file/admin.conf', dest: '{{ ansible_env.HOME }}/.kube/config' }
|
||||
|
||||
- name: setup node
|
||||
shell: |
|
||||
kubeadm join --token {{ token }} {{ endpoint }}
|
||||
sed -i "s/.*server:.*/ server: https:\/\/{{ endpoint }}/g" /etc/kubernetes/kubelet.conf
|
||||
cp {{ path }}/admin.conf $HOME/.kube/config
|
||||
chown $(id -u):$(id -g) $HOME/.kube/config
|
||||
|
||||
- name: restart kubelet
|
||||
systemd:
|
||||
name: kubelet
|
||||
state: restarted
|
||||
@@ -0,0 +1,24 @@
|
||||
[
|
||||
{
|
||||
"variable": "master",
|
||||
"label": "kubernetes master hosts",
|
||||
"description": "hosts to setup kubernetes master",
|
||||
"type": "host",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"variable": "node",
|
||||
"label": "kubenetes node hosts",
|
||||
"description": "hosts to setup kubernetes node",
|
||||
"type": "host",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"variable": "endpoint",
|
||||
"label": "kubernetes entry point",
|
||||
"description": "other can access kubernetes by this",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
- name: clean k8s master
|
||||
hosts: all
|
||||
user: root
|
||||
tasks:
|
||||
- name: kubeadm reset
|
||||
shell: |
|
||||
kubeadm reset
|
||||
|
||||
- name: install kubernetes components
|
||||
yum:
|
||||
state: absent
|
||||
disablerepo: '*'
|
||||
enablerepo: wise2c
|
||||
name: '{{ item }}'
|
||||
with_items:
|
||||
- kubernetes-cni-0.5.1
|
||||
- kubectl-{{ kubernetes_version[1:] }}
|
||||
- kubelet-{{ kubernetes_version[1:] }}
|
||||
- kubeadm-{{ kubernetes_version[1:] }}
|
||||
|
||||
- name: clean link
|
||||
shell: |
|
||||
ip link delete cni0
|
||||
ip link delete flannel.1
|
||||
ignore_errors: true
|
||||
@@ -0,0 +1,15 @@
|
||||
#! /bin/bash
|
||||
|
||||
# while read -r line
|
||||
# do
|
||||
# if [[ "${line}" =~ "server: https://$1:$2" ]]
|
||||
# then printf ${line}
|
||||
# fi
|
||||
# done < /etc/kubernetes/kubelet.conf
|
||||
|
||||
code=`curl -sL -o /dev/null -w %{response_code} http://127.0.0.1:10255/stats`
|
||||
if [ "${code}" == "200" ]; then
|
||||
printf true
|
||||
else
|
||||
printf false
|
||||
fi
|
||||
@@ -0,0 +1,8 @@
|
||||
HOSTNAME=`hostname`
|
||||
while : ; do
|
||||
kubectl label --overwrite nodes ${HOSTNAME,,} io.wise2c.service=$1
|
||||
if [ $? != 0 ]; then
|
||||
sleep 2
|
||||
else break
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,8 @@
|
||||
HOSTNAME=`hostname`
|
||||
while : ; do
|
||||
kubectl taint --overwrite nodes ${HOSTNAME,,} node-role.kubernetes.io=master:NoSchedule
|
||||
if [ $? != 0 ]; then
|
||||
sleep 2
|
||||
else break
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,103 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: flannel
|
||||
namespace: kube-system
|
||||
---
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: kube-flannel-cfg
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: node
|
||||
app: flannel
|
||||
data:
|
||||
cni-conf.json: |
|
||||
{
|
||||
"name": "-cbr0-",
|
||||
"cniVersion": "0.3.0",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "flannel",
|
||||
"delegate": {
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "portmap",
|
||||
"capabilities": {"portMappings": true},
|
||||
"noSnat": false
|
||||
}
|
||||
]
|
||||
}
|
||||
net-conf.json: |
|
||||
{
|
||||
"Network": "10.244.0.0/16",
|
||||
"Backend": {
|
||||
"Type": "vxlan"
|
||||
}
|
||||
}
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: kube-flannel-ds
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: node
|
||||
app: flannel
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
tier: node
|
||||
app: flannel
|
||||
spec:
|
||||
hostNetwork: true
|
||||
nodeSelector:
|
||||
beta.kubernetes.io/arch: amd64
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
serviceAccountName: flannel
|
||||
containers:
|
||||
- name: kube-flannel
|
||||
image: {{ registry_endpoint }}/{{ registry_project }}/flannel:v0.8.0-amd64
|
||||
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr" ]
|
||||
securityContext:
|
||||
privileged: true
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
volumeMounts:
|
||||
- name: run
|
||||
mountPath: /run
|
||||
- name: flannel-cfg
|
||||
mountPath: /etc/kube-flannel/
|
||||
- name: install-cni
|
||||
image: {{ registry_endpoint }}/{{ registry_project }}/flannel:v0.8.0-amd64
|
||||
command: [ "/bin/sh", "-c", "set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conflist; while true; do sleep 3600; done" ]
|
||||
volumeMounts:
|
||||
- name: cni
|
||||
mountPath: /etc/cni/net.d
|
||||
- name: flannel-cfg
|
||||
mountPath: /etc/kube-flannel/
|
||||
volumes:
|
||||
- name: run
|
||||
hostPath:
|
||||
path: /run
|
||||
- name: cni
|
||||
hostPath:
|
||||
path: /etc/cni/net.d
|
||||
- name: flannel-cfg
|
||||
configMap:
|
||||
name: kube-flannel-cfg
|
||||
@@ -0,0 +1,23 @@
|
||||
apiVersion: kubeadm.k8s.io/v1alpha1
|
||||
kind: MasterConfiguration
|
||||
etcd:
|
||||
endpoints:
|
||||
{% for host in groups['etcd'] %}
|
||||
- http://{{ host }}:2379
|
||||
{% endfor %}
|
||||
networking:
|
||||
podSubnet: 10.244.0.0/16
|
||||
kubernetesVersion: {{ kubernetes_version }}
|
||||
token: 904250.ab14566918c0703b
|
||||
tokenTTL: 0s
|
||||
apiServerExtraArgs:
|
||||
apiserver-count: '3'
|
||||
runtime-config: batch/v2alpha1=true
|
||||
feature-gates: LocalStorageCapacityIsolation=true
|
||||
controllerManagerExtraArgs:
|
||||
feature-gates: LocalStorageCapacityIsolation=true
|
||||
schedulerExtraArgs:
|
||||
feature-gates: LocalStorageCapacityIsolation=true
|
||||
apiServerCertSANs:
|
||||
- {{ endpoint.split(':')[0] }}
|
||||
imageRepository: {{ registry_endpoint }}/{{ registry_project }}
|
||||
@@ -0,0 +1,5 @@
|
||||
[Service]
|
||||
Environment="KUBELET_EXTRA_ARGS=--pod-infra-container-image={{ registry_endpoint }}/{{ registry_project }}/pause-amd64:3.0 --feature-gates=LocalStorageCapacityIsolation=true \
|
||||
--kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
|
||||
--system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
|
||||
--enforce-node-allocatable=pods,system-reserved,kube-reserved --eviction-hard=memory.available<500Mi,nodefs.available<10%"
|
||||
@@ -0,0 +1,97 @@
|
||||
# Copyright 2015 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Configuration to deploy release version of the Dashboard UI compatible with
|
||||
# Kubernetes 1.6 (RBAC enabled).
|
||||
#
|
||||
# Example usage: kubectl create -f <this_file>
|
||||
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
name: kubernetes-dashboard
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: kubernetes-dashboard
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: cluster-admin
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: kubernetes-dashboard
|
||||
namespace: kube-system
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: extensions/v1beta1
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
name: kubernetes-dashboard
|
||||
namespace: kube-system
|
||||
spec:
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
spec:
|
||||
containers:
|
||||
- name: kubernetes-dashboard
|
||||
image: {{ registry_endpoint }}/{{ registry_project }}/kubernetes-dashboard-amd64:v1.6.3
|
||||
ports:
|
||||
- containerPort: 9090
|
||||
protocol: TCP
|
||||
args:
|
||||
# Uncomment the following line to manually specify Kubernetes API server Host
|
||||
# If not specified, Dashboard will attempt to auto discover the API server and connect
|
||||
# to it. Uncomment only if the default does not work.
|
||||
# - --apiserver-host=http://my-address:port
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 9090
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 30
|
||||
serviceAccountName: kubernetes-dashboard
|
||||
# Comment the following tolerations if Dashboard must not be deployed on master
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
name: kubernetes-dashboard
|
||||
namespace: kube-system
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 9090
|
||||
nodePort: 30300
|
||||
selector:
|
||||
k8s-app: kubernetes-dashboard
|
||||
@@ -0,0 +1,55 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: max-scale
|
||||
name: max-scale
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: max-scale
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: max-scale
|
||||
name: max-scale
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
value: password
|
||||
- name: REPLICATION_USER
|
||||
value: root
|
||||
- name: REPLICATION_PASSWORD
|
||||
value: password
|
||||
- name: MasterIP
|
||||
value: {{ master }}
|
||||
- name: Slave1IP
|
||||
value: {{ slave1 }}
|
||||
- name: Slave2IP
|
||||
value: {{ slave2 }}
|
||||
- name: MySQLPort
|
||||
value: "3307"
|
||||
- name: NeverMasterIP
|
||||
value: {{ neverMaster }}
|
||||
image: {{ registry }}/{{ project }}/maxscale1.4.5-1-docker:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: max-scale
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
labels:
|
||||
app: max-scale
|
||||
name: max-scale
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- name: 3306-3306
|
||||
port: 3306
|
||||
nodePort: 30308
|
||||
targetPort: 3306
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: max-scale
|
||||
@@ -0,0 +1,6 @@
|
||||
endpoint: {{ .kubernetes.Inherent.endpoint }}
|
||||
token: 904250.ab14566918c0703b
|
||||
registry_endpoint: {{ .registry.Inherent.endpoint }}
|
||||
registry_user: {{ .registry.Inherent.user }}
|
||||
registry_password: {{ .registry.Inherent.password }}
|
||||
registry_project: library
|
||||
@@ -0,0 +1,14 @@
|
||||
[etcd]
|
||||
{{ range $v := .etcd.Hosts.self -}}
|
||||
{{ $v.IP }}
|
||||
{{ end }}
|
||||
|
||||
[master]
|
||||
{{ range $v := .kubernetes.Hosts.master -}}
|
||||
{{ $v.IP }} role=master
|
||||
{{ end }}
|
||||
|
||||
[node]
|
||||
{{ range $v := .kubernetes.Hosts.node -}}
|
||||
{{ $v.IP }} role=node
|
||||
{{ end }}
|
||||
@@ -0,0 +1,5 @@
|
||||
[defaults]
|
||||
inventory=hosts
|
||||
callback_plugins = ../../callback_plugins
|
||||
callback_whitelist = log_back
|
||||
retry_files_enabled = false
|
||||
@@ -0,0 +1,11 @@
|
||||
endpoint: {{ if eq (print .Property.endpoint) "" -}}
|
||||
{{ (index .Hosts.self 0).IP }}
|
||||
{{- else -}}
|
||||
{{ .Property.endpoint }}
|
||||
{{- end }}
|
||||
user: admin
|
||||
password: {{ if eq (print .Property.password) "" -}}
|
||||
Harbor12345
|
||||
{{- else -}}
|
||||
{{ .Property.password }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,17 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
path=`dirname $0`
|
||||
version=$1
|
||||
echo "" >> ${path}/yat/registry.yml.gotmpl
|
||||
echo "version: ${version}" >> ${path}/yat/registry.yml.gotmpl
|
||||
|
||||
curl https://storage.googleapis.com/harbor-releases/harbor-offline-installer-${version}.tgz \
|
||||
-o ${path}/file/harbor-offline-installer-${version}.tgz
|
||||
|
||||
curl -sS https://raw.githubusercontent.com/vmware/harbor/${version}/make/harbor.cfg \
|
||||
| sed \
|
||||
-e "s,hostname = reg\.mydomain\.com,hostname = {{ inventory_hostname }},g" \
|
||||
-e "s,harbor_admin_password = Harbor12345,harbor_admin_password = {{ password }},g" \
|
||||
> ${path}/template/harbor.cfg.j2
|
||||
@@ -0,0 +1,31 @@
|
||||
- name: setup registry
|
||||
hosts: registry
|
||||
user: root
|
||||
vars:
|
||||
path: /var/tmp/wise2c/registry
|
||||
tasks:
|
||||
- name: make registry dir
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: directory
|
||||
mode: 0755
|
||||
with_items:
|
||||
- '{{ cpath }}'
|
||||
- '{{ path }}'
|
||||
|
||||
- name: unarchive harbor
|
||||
unarchive:
|
||||
src: file/harbor-offline-installer-{{ version }}.tgz
|
||||
dest: '{{ cpath }}'
|
||||
|
||||
- name: generate registry config
|
||||
template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
with_items:
|
||||
- { src: 'template/harbor.cfg.j2', dest: '{{ cpath }}/harbor/harbor.cfg' }
|
||||
|
||||
- name: launch registry
|
||||
shell: ./install.sh
|
||||
args:
|
||||
chdir: '{{ cpath }}/harbor'
|
||||
@@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"variable": "self",
|
||||
"label": "registry hosts",
|
||||
"description": "hosts for setup registry",
|
||||
"type": "host",
|
||||
"default": "",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"variable": "endpoint",
|
||||
"label": "registry entry point",
|
||||
"description": "everyone can access registry by this",
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"variable": "password",
|
||||
"label": "registry password",
|
||||
"description": "everyone can 'docker login' use this",
|
||||
"type": "string",
|
||||
"default": "Harbor12345",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
- name: clean registry
|
||||
hosts: registry
|
||||
user: root
|
||||
tasks:
|
||||
- name: stop & rm registry
|
||||
docker_service:
|
||||
project_src: '{{ cpath }}/harbor'
|
||||
state: absent
|
||||
remove_volumes: true
|
||||
|
||||
- name: clean registry directory
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- /data/registry
|
||||
- /data/database
|
||||
- /data/ca_download
|
||||
- /data/config
|
||||
- /data/job_logs
|
||||
- /data/psc
|
||||
- '{{ cpath }}'
|
||||
@@ -0,0 +1,4 @@
|
||||
[registry]
|
||||
{{ range $v := .registry.Hosts.self -}}
|
||||
{{ $v.IP }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,2 @@
|
||||
cpath: /var/lib/wise2c/registry
|
||||
password: {{ .registry.Inherent.password }}
|
||||
Reference in New Issue
Block a user