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

- Forked from ansible-role-example, dump from a previous role.

parent 1f52f9ae
No related branches found
No related tags found
No related merge requests found
Example lxc-host
####### ########
An (empty) example Ansible role complete with working tests out of the box. For Ansible role to configure an LXC host.
more information read the `blog post
<https://www.shore.co.il/blog/ansible-example-role/>`_.
Requirements Requirements
------------ ------------
...@@ -58,3 +56,9 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website ...@@ -58,3 +56,9 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
<https://www.shore.co.il/>`_. Patches are welcome via `git send-email <https://www.shore.co.il/>`_. Patches are welcome via `git send-email
<http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located <http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
at: https://www.shore.co.il/git/. at: https://www.shore.co.il/git/.
TODO
----
- Tests.
- Systemd-networkd DHCP server (fixed in which version of Debian/ Ubuntu).
--- ---
# defaults file for ansible-role-example # defaults file for lxc-host
--- ---
# handlers file for ansible-role-example # handlers file for lxc-host
galaxy_info: galaxy_info:
author: Nimrod Adar author: Nimrod Adar
description: An example Ansible role description: Ansible role to configure an LXC host
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 2.0 min_ansible_version: 2.0
platforms: platforms:
- name: OpenBSD - name: Debian
versions: versions:
- 6.0 - jessie
- stretch
- name: Ubuntu - name: Ubuntu
versions: versions:
- xenial - xenial
galaxy_tags: [ ansible ] galaxy_tags: [ lxc ]
dependencies: [] dependencies:
- src: https://www.shore.co.il/git/ansible-role-networkd
scm: git
name: networkd
- src: https://www.shore.co.il/git/ansible-role-ufw
scm: git
name: ufw
...@@ -11,12 +11,12 @@ vagrant: ...@@ -11,12 +11,12 @@ vagrant:
- name: virtualbox - name: virtualbox
type: virtualbox type: virtualbox
platforms: platforms:
- name: openbsd - name: debian
box: kaorimatz/openbsd-6.0-amd64 box: debian/jessie64
- name: ubuntu - name: ubuntu
box: ubuntu/xenial64 box: ubuntu/xenial64
instances: instances:
- name: ansible-role-example - name: ansible-role-lxc-host
options: options:
append_platform_to_hostname: yes append_platform_to_hostname: yes
raw_config_args: raw_config_args:
......
--- ---
# tasks file for ansible-role-example # tasks file for lxc-host
- name: Assertions - name: Assertions
assert: assert:
that: that:
- ansible_os_family in ['OpenBSD', 'Debian'] - ansible_os_family == 'Debian'
- ansible_distribution_release in ['6.0', 'xenial'] - ansible_service_mgr == 'systemd'
- ansible_distribution_release in ['jessie', 'stretch', 'xenial']
- name: APT install
apt:
name: ['lxc', 'debootstrap', 'yum', 'dnsmasq', 'python-lxc']
state: present
update_cache: yes
cache_valid_time: 3600
- name: Create bridge
with_items:
- lxcbr0.netdev
- lxcbr0.network
template:
src: '{{ item }}.j2'
dest: '/etc/systemd/network/{{ item }}'
owner: root
group: root
mode: 0o0644
notify:
- Restart systemd-networkd
- name: Allow IP forwarding in UFW
ufw:
direction: routed
policy: allow
[NetDev]
Name=lxcbr0
Kind=bridge
[Match]
Name=lxcbr0
[Network]
Address=192.168.123.0/24
DHCPServer=yes
# Doesn't work due to bug #787480.
IPForward=yes
IPMasquerade=yes
--- ---
- hosts: ansible-role-example-openbsd - hosts: ansible-role-lxc-host-ubuntu
gather_facts: false
roles: [openbsd_bootstrap]
- hosts: ansible-role-example-ubuntu
gather_facts: false gather_facts: false
roles: [debian_bootstrap] roles: [debian_bootstrap]
- hosts: all - hosts: all
roles: roles:
- role: ansible-role-example - role: ansible-role-lxc-host
--- ---
# vars file for ansible-role-example # vars file for lxc-host
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment