Git initial commit
This commit is contained in:
commit
d225f220b5
259 files changed
+7059
No files matched your search
Executable
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: setup Cloud Control script
|
||||
template:
|
||||
src: "templates{{ cloud_control_path }}/cloud-control.j2"
|
||||
dest: "{{ cloud_control_path }}/{{ cloud_control_name }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0754
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: install fail2ban service
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
|
||||
install_recommends: yes
|
||||
pkg: fail2ban
|
||||
|
||||
- name: setup fail2ban config jail.local
|
||||
template:
|
||||
backup: yes
|
||||
src: "templates{{ fail2ban_jail_conf }}.j2"
|
||||
dest: "{{ fail2ban_jail_conf }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart fail2ban service
|
||||
|
||||
- name: Install fail2ban filter plugins nginx
|
||||
template:
|
||||
src: "templates{{ fail2ban_path }}/filter.d/{{ filter }}.local.j2"
|
||||
dest: "{{ fail2ban_path }}/filter.d/{{ filter }}.local"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ fail2ban_nginx_filter }}"
|
||||
loop_control:
|
||||
label: "{{ filter }}"
|
||||
loop_var: filter
|
||||
notify: restart fail2ban service
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
---
|
||||
- name: Limit access to cloude home only for root
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ cloud_home }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
recurse: yes
|
||||
|
||||
- name: Install basic apps via apt
|
||||
apt:
|
||||
update_cache: yes
|
||||
autoclean: yes
|
||||
autoremove: yes
|
||||
state: latest
|
||||
install_recommends: yes
|
||||
pkg: "{{ basis_apps }}"
|
||||
|
||||
- name: set timezone
|
||||
timezone:
|
||||
name: "{{ cloud_tzdata }}"
|
||||
|
||||
- name: Setup hahn-cloud users
|
||||
import_tasks: users.yml
|
||||
|
||||
- name: Setup and configure sshd service
|
||||
import_tasks: sshd.yml
|
||||
|
||||
- name: Setup and configure fail2ban service
|
||||
import_tasks: fail2ban.yml
|
||||
|
||||
- name: Setup and configure cloud control script
|
||||
import_tasks: cloud_control.yml
|
||||
|
||||
- name: Setup mount points
|
||||
import_tasks: mount.yml
|
||||
|
||||
- name: Setup swap
|
||||
import_tasks: swap.yml
|
||||
when: swap_on
|
||||
|
||||
- name: Setup basic cloud folders for apps and storage
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ item }}"
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: "{{ shared_group }}"
|
||||
loop:
|
||||
- "{{ cloud_apps }}"
|
||||
- "{{ cloud_storage }}"
|
||||
|
||||
- name: Setup shared python environment for all cloud users
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ cloud_python_envs }}"
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: "{{ shared_group }}"
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
- name: generate filesystem on mounts if not defined
|
||||
filesystem:
|
||||
fstype: "{{ mnt.fstype | default('ext4') }}"
|
||||
dev: "{{ mnt.dev }}"
|
||||
loop: "{{ mount_points }}"
|
||||
loop_control:
|
||||
loop_var: mnt
|
||||
label: "{{ mnt.dev }}: {{ mnt.fstype | default('ext4') }}"
|
||||
|
||||
- name: mount required points
|
||||
mount:
|
||||
path: "{{ mnt.path }}"
|
||||
src: "{{ mnt.dev }}"
|
||||
state: "{{ mnt.state | default('mounted') }}"
|
||||
fstype: "{{ mnt.fstype | default('ext4') }}"
|
||||
opts: "{{ mnt.opts | default('defaults') }}"
|
||||
loop: "{{ mount_points }}"
|
||||
loop_control:
|
||||
loop_var: mnt
|
||||
label: "{{ mnt.dev }}: {{ mnt.path }}"
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: install OpenSSH server
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
|
||||
install_recommends: yes
|
||||
pkg: openssh-server
|
||||
|
||||
- name: setup sshd_config
|
||||
lineinfile:
|
||||
path: "{{ sshd_conf }}"
|
||||
regexp: '^#?{{ configline.split(" ")[0] }}{% if configline.split(" ") | length > 1 %} {% endif %}'
|
||||
line: "{{ configline }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ ssh_configs }}"
|
||||
loop_control:
|
||||
loop_var: configline
|
||||
label: "{{ configline }}"
|
||||
notify: restart sshd service
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: generate file for swapping
|
||||
command:
|
||||
cmd: "dd if=/dev/zero of={{ swap_file }} bs={{ swap_block_size }} count={{ swap_block_count }}"
|
||||
chdir: "/"
|
||||
creates: "{{ swap_file }}"
|
||||
register: swapfile_setup
|
||||
|
||||
- name: prepare swap file
|
||||
command:
|
||||
cmd: "mkswap {{ swap_file }}"
|
||||
chdir: "/"
|
||||
when: swapfile_setup.changed
|
||||
register: swapfile_creation
|
||||
|
||||
- name: set swap permission
|
||||
file:
|
||||
path: "{{ swap_file }}"
|
||||
mode: 0600
|
||||
|
||||
- name: activate swap
|
||||
command:
|
||||
cmd: "swapon {{ swap_file }}"
|
||||
chdir: "/"
|
||||
when: swapfile_creation.changed
|
||||
|
||||
- name: mount swap on boot
|
||||
mount:
|
||||
path: none
|
||||
src: "{{ swap_file }}"
|
||||
fstype: swap
|
||||
opts: sw
|
||||
passno: 0
|
||||
dump: 0
|
||||
state: present
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: list active users
|
||||
shell: cat /etc/passwd | grep -v "nologin" | cut -f 1 -d ":"
|
||||
changed_when: false
|
||||
register: active_users
|
||||
|
||||
- name: Setup required groups of users
|
||||
group:
|
||||
name: "{{ group }}"
|
||||
state: present
|
||||
loop: "{{ ((users | json_query('[*].groups') | flatten) + default_groups) | unique }}"
|
||||
loop_control:
|
||||
loop_var: group
|
||||
label: "{{ group }}"
|
||||
|
||||
- name: Setup users
|
||||
user:
|
||||
name: "{{ user.name }}"
|
||||
state: "{{ user.state }}"
|
||||
comment: "{{ user.displayname }}"
|
||||
group: "{{ user.name }}"
|
||||
groups: "{{ default_groups | default([]) + user.groups }}"
|
||||
append: yes
|
||||
shell: "{{ user.shell }}"
|
||||
loop: "{{ users }}"
|
||||
loop_control:
|
||||
loop_var: user
|
||||
label: "{{ user.name }}"
|
||||
register: new_user_setup
|
||||
|
||||
- name: Setup User ssh_key
|
||||
authorized_key:
|
||||
user: "{{ user.name }}"
|
||||
state: "{{ user.state | default('present') }}"
|
||||
key: "{{ user.ssh_key }}"
|
||||
loop: "{{ users | selectattr('ssh_key', 'defined') | list }}"
|
||||
loop_control:
|
||||
label: "{{ user.name }}"
|
||||
loop_var: user
|
||||
|
||||
- name: Activate password setup for newly created users
|
||||
shell: " set -e pipefail; passwd -d {{ user }}; chage -d0 {{ user }}"
|
||||
loop: "{{ new_user_setup | json_query('results[?changed==`true`].name') | difference(active_users.stdout_lines) }}"
|
||||
loop_control:
|
||||
label: "{{ user }}"
|
||||
loop_var: user
|
||||
when: new_user_setup.changed
|
||||
Reference in new issue
Block a user