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:
hosts:
ariane:
lxc-pet-01:
betam:
fet_container:
fet_containers:
hosts:
lxc-pet-01:
betam:
zyklon:
vars:
ansible_python_interpreter=/usr/bin/python3

View File

@@ -16,3 +16,8 @@
- name: restart smartd
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

@@ -33,5 +33,19 @@
lxc_container:
name: "lxc-{{ item.name }}-{{ item.revision }}"
template: "{{ item.template }}"
container_config: "{{ item.config}}"
container_config: "{{ item.config }}"
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