-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adding logging in order to have better debug info
- adding a docker example
- Loading branch information
Showing
20 changed files
with
445 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import logging | ||
|
||
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) | ||
|
||
RESET_SEQ = "\033[0m" | ||
COLOR_SEQ = "\033[1;%dm" | ||
BOLD_SEQ = "\033[1m" | ||
|
||
def formatter_message(message, use_color = True): | ||
if use_color: | ||
message = message.replace("$RESET", RESET_SEQ).replace("$BOLD", BOLD_SEQ) | ||
else: | ||
message = message.replace("$RESET", "").replace("$BOLD", "") | ||
return message | ||
|
||
COLORS = { | ||
'WARNING': YELLOW, | ||
'INFO': WHITE, | ||
'DEBUG': BLUE, | ||
'CRITICAL': YELLOW, | ||
'ERROR': RED | ||
} | ||
|
||
|
||
def format(): | ||
FORMAT = "[%(levelname)-18s] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)[$BOLD%(name)s$RESET]" | ||
return formatter_message(FORMAT, True) | ||
|
||
|
||
class ColoredFormatter(logging.Formatter): | ||
def __init__(self, msg, use_color = True): | ||
logging.Formatter.__init__(self, msg) | ||
self.use_color = use_color | ||
|
||
def format(self, record): | ||
levelname = record.levelname | ||
if self.use_color and levelname in COLORS: | ||
levelname_color = COLOR_SEQ % (30 + COLORS[levelname]) + levelname + RESET_SEQ | ||
record.levelname = levelname_color | ||
return logging.Formatter.format(self, record) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
all: | ||
|
||
#env vars | ||
DOCKER_COMPOSE_SPEC="docker-compose.yml" | ||
build: | ||
set -e | ||
# re-build docker env | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) build | ||
|
||
start: | ||
# run docker | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) up -d | ||
|
||
clean: | ||
# clean up docker env | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) down --volumes --remove-orphans | ||
|
||
build_and_start: | ||
set -e | ||
# re-build docker env | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) build | ||
# clean up docker env | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) down --volumes --remove-orphans | ||
# run docker | ||
docker-compose -f $(DOCKER_COMPOSE_SPEC) up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Rundeck image with winrm python plugin | ||
|
||
This is an official Rundeck OSS image for testing winrm plugin. | ||
It has a default project example | ||
|
||
## Set python version | ||
On docker-compose.yml set python version you want to try (`PYTHON_VERSION`) | ||
|
||
## Set windows resources model | ||
On `docker/resources` put the Rundeck resource files (xml or yaml) with the windows nodes. | ||
Also, you will need to add the password key storage to connect to the nodes. | ||
|
||
Rundeck will be available on `http://localhost:4441` | ||
|
||
 | ||
|
||
## Build process | ||
|
||
Use `start-docker-example.sh` to build and copy the plugin to the docker image | ||
|
||
## Make commands available | ||
|
||
``` | ||
make build | ||
``` | ||
|
||
``` | ||
make start | ||
``` | ||
|
||
``` | ||
make clean | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3' | ||
|
||
services: | ||
rundeck: | ||
hostname: rundeck | ||
build: | ||
context: rundeck | ||
args: | ||
PYTHON_VERSION: "3.7.3" | ||
environment: | ||
- RUNDECK_GRAILS_URL=http://localhost:4441 | ||
ports: | ||
- "4441:4440" | ||
volumes: | ||
- ${PWD}/resources:/home/rundeck/resources | ||
rundeck-ops: | ||
build: | ||
context: rundeck-ops | ||
links: | ||
- rundeck | ||
environment: | ||
- RUNDECK_URL=http://localhost:4441 | ||
- RUNDECK_NODE_URL=http://rundeck:4440 | ||
- RUNDECK_USER=admin | ||
- RUNDECK_PASSWORD=admin | ||
# import projects | ||
- CONFIG_SCRIPT_POSTSTART=scripts/import_project.sh | ||
#- PROJECTS_LIST=WINRM-DEMO | ||
volumes: | ||
- ${PWD}/projects:/projects |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM ubuntu:16.04 | ||
|
||
## General package configuration | ||
RUN apt-get -y update && \ | ||
apt-get -y install \ | ||
sudo \ | ||
unzip \ | ||
zip \ | ||
curl \ | ||
xmlstarlet \ | ||
netcat-traditional \ | ||
software-properties-common \ | ||
debconf-utils \ | ||
ncurses-bin \ | ||
iputils-ping \ | ||
net-tools \ | ||
apt-transport-https \ | ||
git | ||
|
||
## Install Java | ||
RUN \ | ||
add-apt-repository -y ppa:openjdk-r/ppa && \ | ||
apt-get update && \ | ||
apt-get install -y openjdk-8-jdk | ||
|
||
|
||
# add GPG key | ||
RUN curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" > /tmp/bintray.gpg.key | ||
RUN apt-key add - < /tmp/bintray.gpg.key | ||
|
||
#Install Rundeck CLI tool | ||
RUN echo "deb https://dl.bintray.com/rundeck/rundeck-deb /" | sudo tee -a /etc/apt/sources.list | ||
RUN curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" > /tmp/bintray.gpg.key | ||
RUN apt-key add - < /tmp/bintray.gpg.key | ||
RUN apt-get -y install apt-transport-https | ||
RUN apt-get -y update | ||
RUN apt-get -y install rundeck-cli | ||
|
||
|
||
RUN mkdir -p scripts data | ||
COPY scripts scripts | ||
|
||
RUN chmod -R a+x scripts/* | ||
|
||
CMD scripts/run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
#trap 'echo "rd fail" ; exit 0' EXIT | ||
set -eu | ||
|
||
echo "Sleeping 10s ..." | ||
sleep 10 | ||
|
||
shopt -s nullglob | ||
ARCHIVES=(/projects/*.{jar,zip,groovy}) | ||
shopt -u nullglob | ||
|
||
echo "There are ${#ARCHIVES[*]} project archives to import" | ||
|
||
#default rundeck user password for key storage | ||
echo "rundeck" > tmp.password | ||
|
||
for file in "${ARCHIVES[@]}" | ||
do | ||
echo "Importing archive file $file ..." | ||
|
||
PROJECT_NAME=$(unzip -p "$file" META-INF/MANIFEST.MF|awk '/Rundeck-Archive-Project-Name:/ {print $2}' | tr -d '\r' ) | ||
if ! rd projects info -p "$PROJECT_NAME" >/dev/null 2>&1 | ||
then | ||
echo "Creating project: $PROJECT_NAME ..." | ||
if ! rd projects create -p "$PROJECT_NAME" | ||
then | ||
rc=$? | ||
echo >&2 "WARN: Failed to create project $PROJECT_NAME" | ||
exit $rc | ||
fi | ||
else | ||
echo >&2 "WARN: Project already exists: '$PROJECT_NAME' (skipping)" | ||
fi | ||
|
||
rd projects archives import -f "$file" -p "$PROJECT_NAME" --remove --noExecutions --include-config --include-acl | ||
|
||
done | ||
|
Oops, something went wrong.