2021-10-01 01:02:00 -04:00
|
|
|
- name: create groups
|
2021-09-26 02:32:22 -04:00
|
|
|
group:
|
|
|
|
name: "{{ item.group }}"
|
|
|
|
gid: "{{ item.gid }}"
|
|
|
|
loop:
|
2021-10-03 02:21:43 -04:00
|
|
|
- { group: local, gid: 1000 }
|
|
|
|
- { group: mirror, gid: 1001 }
|
|
|
|
- { group: push, gid: 1002 }
|
|
|
|
- { group: syscom, gid: 10001 }
|
|
|
|
- { group: csc-mirror, gid: 10014 }
|
2021-09-26 02:32:22 -04:00
|
|
|
|
2021-10-03 16:31:41 -04:00
|
|
|
- name: create users
|
2021-10-03 02:21:43 -04:00
|
|
|
# syscom and csc-mirror homes are on /users
|
2021-10-03 16:31:41 -04:00
|
|
|
# can login to every user using password
|
2021-09-26 02:32:22 -04:00
|
|
|
user:
|
|
|
|
uid: "{{ item.uid }}"
|
2021-10-03 02:21:43 -04:00
|
|
|
name: "{{ item.user }}"
|
2021-09-26 02:32:22 -04:00
|
|
|
group: "{{ item.user }}"
|
2021-10-03 16:31:41 -04:00
|
|
|
shell: "{{ item.shell }}"
|
2021-09-26 02:32:22 -04:00
|
|
|
create_home: "{{ item.home }}"
|
2021-10-03 16:31:41 -04:00
|
|
|
password: "{{ 'password' | password_hash('sha512') }}"
|
|
|
|
update_password: on_create
|
2021-09-26 02:32:22 -04:00
|
|
|
loop:
|
2021-10-03 18:30:51 -04:00
|
|
|
- { user: local, uid: 1000, shell: /bin/bash, home: yes }
|
2021-10-03 16:31:41 -04:00
|
|
|
- { user: mirror, uid: 1001, shell: /bin/bash, home: yes }
|
|
|
|
- { user: push, uid: 1002, shell: /bin/sh, home: no }
|
|
|
|
- { user: syscom, uid: 10001, shell: /bin/bash, home: no }
|
|
|
|
- { user: csc-mirror, uid: 10014, shell: /bin/bash, home: no }
|
2021-09-26 02:32:22 -04:00
|
|
|
|
|
|
|
- name: add mirror to push group
|
|
|
|
user:
|
|
|
|
name: mirror
|
|
|
|
groups: push
|
|
|
|
append: yes
|
|
|
|
|
2021-10-01 01:02:00 -04:00
|
|
|
- name: create /mirror
|
|
|
|
file:
|
|
|
|
path: /mirror
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
|
|
|
|
|
|
|
- name: create /mirror/merlin
|
2021-09-26 02:32:22 -04:00
|
|
|
file:
|
|
|
|
path: /mirror/merlin
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
|
|
|
|
|
|
|
- name: create /mirror/root
|
|
|
|
file:
|
|
|
|
path: /mirror/root
|
|
|
|
state: directory
|
|
|
|
owner: mirror
|
|
|
|
group: syscom
|
|
|
|
mode: "0775"
|
|
|
|
|
|
|
|
- name: create zfs mountpoint
|
2021-10-03 16:31:41 -04:00
|
|
|
# only .cscmirror1 is owned by mirror
|
|
|
|
# .cscmirror(2|3) are owned by root
|
2021-09-26 02:32:22 -04:00
|
|
|
file:
|
|
|
|
path: /mirror/root/.cscmirror
|
2021-10-03 16:31:41 -04:00
|
|
|
state: directory
|
2021-09-26 02:32:22 -04:00
|
|
|
owner: mirror
|
|
|
|
group: mirror
|
|
|
|
mode: "0755"
|
|
|
|
|
2021-09-15 00:46:18 -04:00
|
|
|
- name: install zfs
|
|
|
|
apt:
|
|
|
|
name: zfsutils-linux
|
2021-09-22 00:50:14 -04:00
|
|
|
state: present
|
|
|
|
update_cache: yes
|
2021-09-15 00:46:18 -04:00
|
|
|
|
2021-09-26 02:32:22 -04:00
|
|
|
# create the var using
|
2021-09-17 16:42:15 -04:00
|
|
|
# vars:
|
|
|
|
# disks:
|
|
|
|
# - /dev/vdc
|
|
|
|
# - /dev/vdd
|
|
|
|
# - /dev/vde
|
|
|
|
# - /dev/vdf
|
|
|
|
# disk_arg: "{{ disks | join(' ') }}"
|
|
|
|
|
|
|
|
# hardcoded for now
|
|
|
|
# may be better to use the /dev/disk/by-id/... instead
|
|
|
|
- name: disks to be used for zpool
|
|
|
|
set_fact:
|
|
|
|
disks:
|
|
|
|
- /dev/vdc
|
|
|
|
- /dev/vdd
|
|
|
|
- /dev/vde
|
|
|
|
- /dev/vdf
|
|
|
|
|
2021-10-01 01:02:00 -04:00
|
|
|
- name: join disk pathes onto one line
|
2021-09-17 16:42:15 -04:00
|
|
|
set_fact:
|
|
|
|
disk_arg: "{{ disks | join(' ') }}"
|
|
|
|
|
|
|
|
- name: zpool exists
|
2021-09-26 16:22:29 -04:00
|
|
|
command: "zpool status cscmirror"
|
2021-09-22 00:50:14 -04:00
|
|
|
changed_when: false
|
2021-09-17 16:42:15 -04:00
|
|
|
ignore_errors: true
|
2021-09-22 00:50:14 -04:00
|
|
|
register: zpool_exists
|
2021-09-17 16:42:15 -04:00
|
|
|
|
2021-09-11 23:56:31 -04:00
|
|
|
- name: create and mount zpool
|
2021-09-17 16:42:15 -04:00
|
|
|
command: >
|
|
|
|
zpool create
|
|
|
|
-m /mirror/root/.cscmirror
|
|
|
|
cscmirror
|
|
|
|
raidz2
|
|
|
|
{{ disk_arg }}
|
2021-10-03 18:30:51 -04:00
|
|
|
when: zpool_exists.rc != 0
|