Skip to content
Snippets Groups Projects
Commit a88c733b authored by nimrod's avatar nimrod
Browse files

First comit.

parents
No related branches found
No related tags found
No related merge requests found
.vagrant
*.swp
*.swo
*~
~*
FROM phusion/baseimage
RUN apt-get update
RUN apt-get install -yf vim-nox git python-dev python-pip
RUN pip install ansible
RUN rm -f /etc/service/sshd/down
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
COPY ./ /root
EXPOSE 22
CMD /sbin/my_init --enable-insecure-key
detect-container
================
For a while now contaner detection inside Ansible worked only when running on
bare metal and not inside a VM (like an AWS instance). This repository is a test
for a tool to detect containerization. However with commit
https://github.com/ansible/ansible/commit/45f98007540ac9ac1694a8505e2ad763bf135d57
to Ansible this is no longer an issue, so this repository and tool is no longer
maitained (the detection works AFAIK, but the testing environment is not
finished).
License
-------
This code is under the public domain.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "debian" do |debian|
debian.vm.box = "debian/jessie64"
end
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.box = "ubuntu/trusty64"
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
ansible.sudo = true
end
end
[default]
inventory = inventory
#!/usr/bin/env python2
'''
Detection if running in a container and if so, which.
Must run as root.
'''
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import os
def detect_nspawn():
raise NotImplemented
def detect_lxc():
try:
env = open('/proc/1/environ', 'r').read()
return env.find('container=lxc') > -1
except:
return False
def detect_docker():
return os.path.isfile('''/.dockerenv''')
if __name__ == '__main__':
if detect_lxc():
print('lxc')
elif detect_docker():
print('docker')
# elif detect_nspawn:
# print('nspawn')
else:
print('None')
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA1ZswRub+3DvSEnBiyM5YRpRzRYV88vO1X2j867u6pyCHUNXv
RRCr7ahMLPIVYsZwlHb4sF+Zb3DJOBH+E265o93chdMxbWG44k0spf10JRevA0JX
NrEwHR8vesCR74e5MuddbSic88lsEqn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r5Xe
T2Nz3BHHnZXYJVEuzcddeocCgYEAnhDjPAHtw2p0Inxlb9kPb6aBC/ECcwtBSUkL
IOy/BZA1HPnxs89eNFAtmwQ8k2o6lXDDSJTJSuZj5CdGVKfuU8aOUJz/Tm2eudxL
A/+jLJhJyCBthhcJyx3m04E4CAr+5ytyKeP9qXPMvoghcNg66/UabuKYV+CU+feX
8xUa7NkCgYEAlX8HGvWMmiG+ZRFB//3Loy87bBxGlN0pUtCEScabZxdB2HkI9Vp7
Yr67QIZ3y7T88Mhkwam54JCjiV+3TZbSyRMOjkqf7UhTCZC6hHNqdUnlpv4bJWeW
i5Eun8ltYxBnemNc2QGxA4r+KCspi+pRvWNGzL3PFVBGXiLsmOMul78=
-----END RSA PRIVATE KEY-----
[localhost]
localhost ansible_connection=local
docker ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_private_key_file=insecure_key ansible_ssh_user=root
lxc ansible_ssh_host=10.0.3.78 ansible_ssh_user=ubuntu ansible_ssh_private_key=~/.ssh/id_rsa ansible_become=True ansible_become_user=root ansibe_become_method=sudo ansible_become_pass=ubuntu
---
- hosts:
- all
tasks:
- name: apt install
apt:
name: '{{ item }}'
state: present
update_cache: yes
cache_valid_time: 3600
with_items:
- apt-transport-https
- ca-certificates
- vim-nox
- python-dev
- python-pip
- git
- lxc
- build-essential
- name: Add Docker repo key
apt_key:
keyserver: hkp://p80.pool.sks-keyservers.net:80
id: 58118E89F3A912897C070ADBF76221572C52609D
state: present
- name: Add Docker repo
apt_repository:
repo: 'deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_distribution_release }} main'
state: present
update_cache: yes
- name: Install Docker
apt:
name: docker-engine
state: present
update_cache: yes
cache_valid_time: 3600
- name: pip install
pip:
name: '{{ item }}'
state: present
with_items:
- ansible
ansible>=1.9.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment