summaryrefslogtreecommitdiff
path: root/common/tasks
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2019-01-21 22:48:09 +0100
committerRobin Krahl <me@robin-krahl.de>2019-01-21 23:02:41 +0100
commit06e0f212a9f944e11851cdad57aa5efd02594370 (patch)
tree0504a946a70ed0734201f7f1094dbc6d6bbdf6eb /common/tasks
downloadansible-roles-06e0f212a9f944e11851cdad57aa5efd02594370.tar.gz
ansible-roles-06e0f212a9f944e11851cdad57aa5efd02594370.tar.bz2
Add common role for basic system setup
Diffstat (limited to 'common/tasks')
-rw-r--r--common/tasks/main.yaml6
-rw-r--r--common/tasks/packages.yaml16
-rw-r--r--common/tasks/sh.yaml8
-rw-r--r--common/tasks/ssh.yaml14
-rw-r--r--common/tasks/sudo.yaml13
-rw-r--r--common/tasks/user.yaml12
6 files changed, 69 insertions, 0 deletions
diff --git a/common/tasks/main.yaml b/common/tasks/main.yaml
new file mode 100644
index 0000000..819cbe6
--- /dev/null
+++ b/common/tasks/main.yaml
@@ -0,0 +1,6 @@
+---
+- include: packages.yaml
+- include: sh.yaml
+- include: ssh.yaml
+- include: sudo.yaml
+- include: user.yaml
diff --git a/common/tasks/packages.yaml b/common/tasks/packages.yaml
new file mode 100644
index 0000000..41b0aeb
--- /dev/null
+++ b/common/tasks/packages.yaml
@@ -0,0 +1,16 @@
+---
+- name: Install packages
+ package:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - bash
+ - dash
+ - "{{ openssh_server }}"
+ - sudo
+- name: Update all packages
+ apt:
+ name: "*"
+ state: latest
+ force_apt_get: true
+ update_cache: true
diff --git a/common/tasks/sh.yaml b/common/tasks/sh.yaml
new file mode 100644
index 0000000..6bc561e
--- /dev/null
+++ b/common/tasks/sh.yaml
@@ -0,0 +1,8 @@
+---
+- name: Configure dash as default sh
+ file:
+ src: /bin/sh
+ dest: dash
+ owner: root
+ group: root
+ state: link
diff --git a/common/tasks/ssh.yaml b/common/tasks/ssh.yaml
new file mode 100644
index 0000000..6adc5d3
--- /dev/null
+++ b/common/tasks/ssh.yaml
@@ -0,0 +1,14 @@
+- name: Copy sshd configuration
+ copy:
+ src: sshd_config
+ dest: /etc/ssh/sshd_config
+ owner: root
+ group: root
+ mode: u=rw,g=r,o=r
+ notify:
+ - reload sshd
+- name: Enable and start sshd
+ service:
+ name: sshd
+ enabled: yes
+ state: started
diff --git a/common/tasks/sudo.yaml b/common/tasks/sudo.yaml
new file mode 100644
index 0000000..468dd5b
--- /dev/null
+++ b/common/tasks/sudo.yaml
@@ -0,0 +1,13 @@
+---
+- name: Create sudo group
+ group:
+ name: sudo
+ gid: 27
+ state: present
+- name: Copy sudo configuration
+ copy:
+ src: sudoers
+ dest: /etc/sudoers
+ owner: root
+ group: root
+ mode: u=r,g=r,o=
diff --git a/common/tasks/user.yaml b/common/tasks/user.yaml
new file mode 100644
index 0000000..e8e5eb4
--- /dev/null
+++ b/common/tasks/user.yaml
@@ -0,0 +1,12 @@
+- name: "Create user {{ user_name }}"
+ user:
+ name: "{{ user_name }}"
+ comment: "{{ user_full_name }}"
+ shell: /bin/bash
+ uid: 1000
+ groups:
+ - sudo
+- name: "Configure authorized key for {{ user_name }}"
+ authorized_key:
+ user: "{{ user_name }}"
+ key: "{{ user_ssh_key }}"