--- /dev/null
+- name: Update local user phd
+ hosts: localhost
+ gather_facts: false
+ vars:
+ system_groups: root,adm,disk,cdrom,floppy,sudo,audio,www-data,video,plugdev,staff,users,Debian-exim,fuse,sambashare,bluetooth,davfs2,vboxusers,input
+ tasks:
+ - name: Create system groups
+ become: true
+ group:
+ name: "{{ item }}"
+ system: true
+ loop: "{{ system_groups.split(',') }}"
+ - name: Create group phd
+ become: true
+ group:
+ name: phd
+ - name: user phd
+ become: true
+ user:
+ name: phd
+ groups: "{{ system_groups }}"
--- /dev/null
+- name: Create user phd
+ hosts: "{{ hosts | default('servers') }}"
+ gather_facts: false
+ roles:
+ - debian-sudo
+ - debian-phd
+ - debian-init-system
+++ /dev/null
-- name: Create user phd
- hosts: "{{ hosts | default('servers') }}"
- gather_facts: false
- vars:
- system_groups: root,adm,disk,cdrom,floppy,sudo,audio,www-data,video,plugdev,staff,users,Debian-exim,fuse,sambashare,input
- tasks:
- - name: Create system groups
- become: true
- group:
- name: "{{ item }}"
- system: true
- loop: "{{ system_groups.split(',') }}"
- - name: Create group phd
- become: true
- group:
- name: phd
- - name: Add user phd
- become: true
- user:
- name: phd
- group: phd
- groups: "{{ system_groups }}"
- - name: Create folder ~phd/.ssh
- file:
- path: ~phd/.ssh
- state: directory
- owner: phd
- group: phd
- mode: 0700
- - name: Upload SSH key
- copy:
- src: ~/.ssh/phd@nb3.pub
- dest: ~phd/.ssh/phd@nb3.pub
- owner: phd
- group: phd
- mode: 0600
-- name: Update local user phd
- hosts: localhost
- gather_facts: false
- vars:
- system_groups: root,adm,disk,cdrom,floppy,sudo,audio,www-data,video,plugdev,staff,users,Debian-exim,fuse,sambashare,bluetooth,davfs2,vboxusers,input
- tasks:
- - name: Create system groups
- become: true
- group:
- name: "{{ item }}"
- system: true
- loop: "{{ system_groups.split(',') }}"
- - name: Create group phd
- become: true
- group:
- name: phd
- - name: user phd
- become: true
- user:
- name: phd
- groups: "{{ system_groups }}"
--- /dev/null
+Init new Debian system: install minimal list of packages.
--- /dev/null
+- name: Install minimal software packages
+ become: true
+ apt:
+ autoclean: yes
+ autoremove: yes
+ install_recommends: no
+ name: ['apt', 'aptitude', 'dselect', 'bash', 'bash-completion', 'mc', 'python', 'python3', 'rsync', 'vim']
+ purge: yes
+ state: latest
+ update_cache: yes
--- /dev/null
+Init remote user phd: create system and user groups, create the user,
+upload SSH public key.
--- /dev/null
+system_groups: root,adm,disk,cdrom,floppy,sudo,audio,www-data,video,plugdev,staff,users,Debian-exim,fuse,sambashare,input
--- /dev/null
+- name: Create system groups
+ become: true
+ group:
+ name: "{{ item }}"
+ system: true
+ loop: "{{ system_groups.split(',') }}"
+- name: Create group phd
+ become: true
+ group:
+ name: phd
+- name: Add user phd
+ become: true
+ user:
+ name: phd
+ group: phd
+ groups: "{{ system_groups }}"
+- name: Create folder ~phd/.ssh
+ file:
+ path: ~phd/.ssh
+ state: directory
+ owner: phd
+ group: phd
+ mode: 0700
+- name: Upload SSH key
+ copy:
+ src: ~/.ssh/phd@nb3.pub
+ dest: ~phd/.ssh/authorized_keys
+ owner: phd
+ group: phd
+ mode: 0600
--- /dev/null
+Init sudo: install sudo, add user phd, allow passwordless operations.
--- /dev/null
+- name: Install sudo
+ become: true
+ apt:
+ install_recommends: no
+ name: sudo
+ state: latest
+ update_cache: yes
+- name: Add user phd to group sudo
+ become: true
+ user:
+ name: phd
+ append: yes
+ groups: sudo
+- name: Allow passwordless operations
+ become: true
+ copy:
+ content: 'phd ALL=(ALL:ALL) NOPASSWD: ALL'
+ dest: /etc/sudoers.d/phd
+ owner: root
+ group: sudo
+ mode: 0640
+ force: yes