Initial commit

This commit is contained in:
Jan Beilicke 2020-03-24 00:55:53 +01:00
commit 549ca9b641
12 changed files with 222 additions and 0 deletions

4
tasks/ansible-debian.yml Normal file
View file

@ -0,0 +1,4 @@
---
- name: Install Ansible
raw: test -e /usr/local/bin/ansible || pip3 install ansible
changed_when: false

22
tasks/locales-debian.yml Normal file
View file

@ -0,0 +1,22 @@
---
- name: Generate locals
locale_gen:
name: "{{ item }}"
state: present
loop: "{{ locales_gen }}"
- name: Get current locale
command: localectl status
register: locale_status
changed_when: false
- name: Extract LANG from current locale configuration
set_fact:
locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}"
- debug:
msg: "{{ locale_lang }}"
- name: Set default locale
command: localectl set-locale LANG={{ locales_default }}
when: locale_lang != locales_default

26
tasks/main.yml Normal file
View file

@ -0,0 +1,26 @@
---
# tasks file for common
- include: locales-debian.yml
become: true
when: ansible_facts['os_family'] == 'Debian'
- include: users.yml
become: true
- include: python-debian.yml
become: true
when: ansible_facts['os_family'] == 'Debian'
- include: ansible-debian.yml
become: true
- name: Install basic packages
apt:
name: "{{ packages }}"
state: present
#update_cache: yes
vars:
packages:
- htop
- tmux
become: yes
- name: Copy tmux config
copy: src=files/tmux.conf dest=/home/{{ ansible_user }}/.tmux.conf mode=0644

8
tasks/python-debian.yml Normal file
View file

@ -0,0 +1,8 @@
---
- name: Install Python3
raw: test -e /usr/bin/python3 || (apt update && apt install -y --force-yes python3)
changed_when: false
- name: Install pip3
raw: test -e /usr/bin/pip3 || (apt update && apt install -y --force-yes python3-pip)
changed_when: false

49
tasks/users.yml Normal file
View file

@ -0,0 +1,49 @@
---
- name: 'Install required packages'
pkgng: name={{item}} state=present
with_items:
- sudo
when: ansible_facts['os_family'] == 'FreeBSD'
- name: 'Allow wheel group to do passwordless sudo'
lineinfile:
dest: /usr/local/etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD:ALL'
validate: visudo -cf %s
when: ansible_facts['os_family'] == 'FreeBSD'
- name: 'Allow wheel group to do passwordless sudo'
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD:ALL'
validate: visudo -cf %s
when: ansible_facts['os_family'] == 'Debian'
- name: 'Create users with corresponding groups'
user:
name: "{{ item }}"
groups: users
with_items: "{{ users }}"
- name: 'Add corresponding authorized_keys to each user'
authorized_key:
user: "{{ item }}"
state: present
key: "{{ lookup('file', 'public_keys/id_{{ item }}.pub') }}"
with_items: "{{ users }}"
- name: 'Ensure that wheel group is existing'
group:
name: wheel
state: present
- name: 'Add sudoers user to wheel group'
user:
name: "{{ item }}"
groups: wheel
append: yes
with_items: "{{ sudoers }}"