Add LXC initial SSH setup

This commit is contained in:
Daniel A. Maierhofer
2018-03-17 16:25:24 +01:00
parent 3150d171be
commit 6e4edfb5a8
4 changed files with 24 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
---
common_apt: False

View File

@@ -3,11 +3,10 @@ all:
fet_hosts: fet_hosts:
hosts: hosts:
ariane: ariane:
lxc-pet-01: fet_containers:
betam:
fet_container:
hosts: hosts:
lxc-pet-01: lxc-pet-01:
betam: betam:
zyklon:
vars: vars:
ansible_python_interpreter=/usr/bin/python3 ansible_python_interpreter=/usr/bin/python3

View File

@@ -16,3 +16,8 @@
- name: restart smartd - name: restart smartd
service: name=smartd state=restarted service: name=smartd state=restarted
- name: lxc - create authorized_keys file in VM for root
listen: lxc - inital ssh authorized_keys
copy: remote_src=yes src=/root/.ssh/authorized_keys dest="/var/lib/lxc/lxc-{{ item.name }}-{{ item.revision }}/rootfs/root/.ssh/authorized_keys" owner=root group=root mode=0600
with_items: "{{ lxc.containers }}"

View File

@@ -35,3 +35,17 @@
template: "{{ item.template }}" template: "{{ item.template }}"
container_config: "{{ item.config }}" container_config: "{{ item.config }}"
with_items: "{{ lxc.containers }}" with_items: "{{ lxc.containers }}"
notify: lxc - inital ssh setup
- name : lxc - enable ssh on voidlinux
lxc_container:
name: "lxc-{{ item.name }}-{{ item.revision }}"
container_command: "ln -s /etc/sv/{sshd,dhcpcd-eth0} /var/service/"
when: item.template == "voidlinux"
changed_when: False
with_items: "{{ lxc.containers }}"
- name: lxc - create .ssh directory for root in VM
file: path="/var/lib/lxc/lxc-{{ item.name }}-{{ item.revision }}/rootfs/root/.ssh" state=directory owner=root group=root mode=0700
with_items: "{{ lxc.containers }}"
notify: lxc - inital ssh authorized_keys