forked from pytest-dev/pytest-testinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes pytest-dev#67
- Loading branch information
Showing
14 changed files
with
178 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ coverage.xml | |
flake8.report | ||
junit*.xml | ||
doc/build | ||
.vagrant | ||
.cache |
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 |
---|---|---|
@@ -1,14 +1,25 @@ | ||
sudo: required | ||
services: | ||
- docker | ||
env: | ||
global: | ||
- DOCKER_VERSION=1.10.2-0~trusty | ||
- DOCKER_COMPOSE_VERSION=1.6.2 | ||
language: python | ||
python: 2.7 | ||
before_install: | ||
- wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb | ||
- sudo dpkg -i vagrant_1.8.1_x86_64.deb | ||
- for image in debian_wheezy debian_jessie ubuntu_trusty centos_7 fedora_21; do docker pull philpep/testinfra:$image; done | ||
- vagrant up --provider=docker | ||
- apt-cache madison docker-engine | ||
- sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION} | ||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose | ||
- chmod +x docker-compose | ||
- sudo mv docker-compose /usr/local/bin | ||
- docker version | ||
- docker-compose version | ||
- for image in debian_wheezy debian_jessie ubuntu_trusty centos_7; do docker pull philpep/testinfra:$image; done | ||
- docker-compose up -d | ||
install: | ||
- pip install tox | ||
script: | ||
- tox | ||
after_script: | ||
- docker-compose kill |
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 was deleted.
Oops, something went wrong.
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,24 @@ | ||
version: '2' | ||
services: | ||
debian_wheezy: | ||
build: images/debian_wheezy | ||
hostname: debian_wheezy | ||
|
||
debian_jessie: | ||
build: images/debian_jessie | ||
privileged: true | ||
hostname: debian_jessie | ||
|
||
centos_7: | ||
build: images/centos_7 | ||
privileged: true | ||
hostname: centos_7 | ||
|
||
fedora: | ||
build: images/fedora | ||
privileged: true | ||
hostname: fedora | ||
|
||
ubuntu_trusty: | ||
build: images/ubuntu_trusty | ||
hostname: ubuntu_trusty |
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,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI | ||
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP | ||
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 | ||
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO | ||
Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW | ||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehU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6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ | ||
kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH | ||
+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ | ||
NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= | ||
-----END RSA PRIVATE KEY----- |
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
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,70 @@ | ||
# -*- coding: utf8 -*- | ||
# Copyright © 2016 Philippe Pepiot | ||
# | ||
# 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. | ||
|
||
from __future__ import print_function | ||
|
||
import testinfra | ||
|
||
template = """ | ||
Host %s | ||
HostName %s | ||
User root | ||
Port 22 | ||
UserKnownHostsFile /dev/null | ||
StrictHostKeyChecking no | ||
PasswordAuthentication no | ||
IdentityFile .cache/insecure_private_key | ||
IdentitiesOnly yes | ||
LogLevel FATAL | ||
""" | ||
|
||
|
||
class DockerComposeService(object): | ||
_services = None | ||
|
||
@classmethod | ||
def get_services(cls): | ||
if cls._services is not None: | ||
return cls._services | ||
|
||
cls._services = {} | ||
Command = testinfra.get_backend("local://").get_module("Command") | ||
|
||
for line in Command.check_output(( | ||
"docker-compose ps -q | xargs docker inspect --format " | ||
"""'{{ index .Config.Labels "com.docker.compose.service" }} """ | ||
"""{{ .Name }} """ | ||
"""{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'""" | ||
)).splitlines(): | ||
service, name, ip = line.split() | ||
cls._services[service] = { | ||
"name": name[1:] if name[0] == "/" else name, | ||
"ip": ip, | ||
} | ||
|
||
return cls._services | ||
|
||
@classmethod | ||
def get(cls, service): | ||
return cls.get_services()[service] | ||
|
||
|
||
def docker_compose_to_ssh_config(): | ||
for service, values in DockerComposeService.get_services().items(): | ||
print(template % (service, values["ip"])) | ||
|
||
|
||
if __name__ == "__main__": | ||
docker_compose_to_ssh_config() |
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