Compare commits
16 commits
7c6810a945
...
ef9cfb8ced
Author | SHA1 | Date | |
---|---|---|---|
ef9cfb8ced | |||
0a845c7097 | |||
0eb60eb187 | |||
1cbbba0dea | |||
2f9c04c49f | |||
01d8b7e3dc | |||
56c7b95bb5 | |||
1105acdcc1 | |||
8194cd6799 | |||
6335b7735a | |||
0448703897 | |||
2a27db4ba8 | |||
2953f200a1 | |||
5397ef058a | |||
ffa58f35e3 | |||
fa1f9e2bf5 |
6 changed files with 106 additions and 43 deletions
17
README.md
17
README.md
|
@ -12,16 +12,26 @@ Role Variables
|
||||||
Defaults:
|
Defaults:
|
||||||
|
|
||||||
```
|
```
|
||||||
hostname: {{ inventory_hostname }}
|
hostname: "{{ inventory_hostname }}"
|
||||||
update_hostname: no
|
update_hostname: yes
|
||||||
locales_gen:
|
locales_gen:
|
||||||
- en_US.UTF-8
|
- en_US.UTF-8
|
||||||
- de_DE.UTF-8
|
- de_DE.UTF-8
|
||||||
locales_default: de_DE.UTF-8
|
locales_default: de_DE.UTF-8
|
||||||
|
x11_keymap: de
|
||||||
users:
|
users:
|
||||||
- vagrant
|
- vagrant
|
||||||
sudoers:
|
sudoers:
|
||||||
- vagrant
|
- vagrant
|
||||||
|
enable_ansible: no
|
||||||
|
# Will install a specific Ansible version on the target host
|
||||||
|
ensure_ansible_version: 2.10.3
|
||||||
|
# Allow sudo with a password (applied to group sudo)
|
||||||
|
enable_sudo: yes
|
||||||
|
# Allow passwordless sudo (applied to group wheel)
|
||||||
|
enable_passwordless_sudo: yes
|
||||||
|
# Skip provisioning of the firewall
|
||||||
|
skip_firewall: no
|
||||||
```
|
```
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
|
@ -33,7 +43,8 @@ Example Playbook
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
MIT
|
- BSD-3-Clause
|
||||||
|
- MIT
|
||||||
|
|
||||||
Author Information
|
Author Information
|
||||||
------------------
|
------------------
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
# defaults file for common
|
# defaults file for common
|
||||||
hostname: '{{ inventory_hostname }}'
|
hostname: "{{ inventory_hostname }}"
|
||||||
update_hostname: yes
|
update_hostname: yes
|
||||||
locales_gen:
|
locales_gen:
|
||||||
- en_US.UTF-8
|
- en_US.UTF-8
|
||||||
|
@ -11,4 +11,13 @@ users:
|
||||||
- vagrant
|
- vagrant
|
||||||
sudoers:
|
sudoers:
|
||||||
- vagrant
|
- vagrant
|
||||||
|
enable_ansible: no
|
||||||
|
# Will install a specific Ansible version on the target host
|
||||||
ensure_ansible_version: 2.10.3
|
ensure_ansible_version: 2.10.3
|
||||||
|
# Allow sudo with a password (applied to group sudo)
|
||||||
|
enable_sudo: yes
|
||||||
|
# Allow passwordless sudo (applied to group wheel)
|
||||||
|
enable_passwordless_sudo: yes
|
||||||
|
# Skip provisioning of the firewall
|
||||||
|
skip_firewall: no
|
||||||
|
authorized_keys_are_exclusive: false # Be careful, this will delete non-Ansible-managed authorized keys from the target!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: your name
|
author: jotbe
|
||||||
description: your description
|
description: Common packages and configuration
|
||||||
company: your company (optional)
|
company: ""
|
||||||
|
|
||||||
# If the issue tracker for your role is not on github, uncomment the
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
# next line and provide a value
|
# next line and provide a value
|
||||||
|
@ -14,7 +14,9 @@ galaxy_info:
|
||||||
# - GPL-3.0-only
|
# - GPL-3.0-only
|
||||||
# - Apache-2.0
|
# - Apache-2.0
|
||||||
# - CC-BY-4.0
|
# - CC-BY-4.0
|
||||||
license: license (GPL-2.0-or-later, MIT, etc)
|
license:
|
||||||
|
- BSD-3-Clause
|
||||||
|
- MIT
|
||||||
|
|
||||||
min_ansible_version: 2.4
|
min_ansible_version: 2.4
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
---
|
---
|
||||||
- name: Install Ansible
|
- name: Install Ansible
|
||||||
raw: which ansible || pip3 install ansible
|
raw: which ansible || python3 -m pip install ansible
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
|
@ -12,10 +12,13 @@
|
||||||
import_role:
|
import_role:
|
||||||
name: geerlingguy.firewall
|
name: geerlingguy.firewall
|
||||||
tags: firewall
|
tags: firewall
|
||||||
|
when: not skip_firewall
|
||||||
|
|
||||||
- include: locales-debian.yml
|
- include: locales-debian.yml
|
||||||
become: true
|
become: true
|
||||||
when: ansible_facts['os_family'] == 'Debian'
|
when:
|
||||||
|
- ansible_facts['os_family'] == 'Debian'
|
||||||
|
- not ansible_is_chroot
|
||||||
|
|
||||||
- include: users.yml
|
- include: users.yml
|
||||||
become: true
|
become: true
|
||||||
|
@ -28,10 +31,12 @@
|
||||||
pacman:
|
pacman:
|
||||||
name: "{{ packages }}"
|
name: "{{ packages }}"
|
||||||
state: present
|
state: present
|
||||||
#update_cache: yes
|
update_cache: yes
|
||||||
vars:
|
vars:
|
||||||
packages:
|
packages:
|
||||||
- python-pip
|
- python-pip
|
||||||
|
- python-setuptools
|
||||||
|
- python-virtualenv
|
||||||
- htop
|
- htop
|
||||||
- tmux
|
- tmux
|
||||||
become: yes
|
become: yes
|
||||||
|
@ -44,6 +49,9 @@
|
||||||
#update_cache: yes
|
#update_cache: yes
|
||||||
vars:
|
vars:
|
||||||
packages:
|
packages:
|
||||||
|
- python3-pip
|
||||||
|
- python3-setuptools
|
||||||
|
- python3-virtualenv
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- htop
|
- htop
|
||||||
- tmux
|
- tmux
|
||||||
|
@ -53,3 +61,10 @@
|
||||||
- name: Install Ansible
|
- name: Install Ansible
|
||||||
pip:
|
pip:
|
||||||
name: ansible=={{ ensure_ansible_version }}
|
name: ansible=={{ ensure_ansible_version }}
|
||||||
|
when: enable_ansible
|
||||||
|
|
||||||
|
- name: Install tmuxp
|
||||||
|
pip:
|
||||||
|
name:
|
||||||
|
- tmuxp
|
||||||
|
state: present
|
||||||
|
|
|
@ -5,51 +5,77 @@
|
||||||
- sudo
|
- sudo
|
||||||
when: ansible_facts['os_family'] == 'FreeBSD'
|
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'] in ['Debian', 'Archlinux']
|
|
||||||
|
|
||||||
- name: 'Create users with corresponding groups'
|
- name: 'Create users with corresponding groups'
|
||||||
user:
|
user:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
groups: users
|
groups: users
|
||||||
with_items: "{{ users }}"
|
with_items: "{{ users }}"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: 'Ensure that sudo group is existing'
|
||||||
|
group:
|
||||||
|
name: sudo
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: 'Allow sudo group to do sudo'
|
||||||
|
lineinfile:
|
||||||
|
dest: "{{ lookup('first_found', files, errors='ignore') }}"
|
||||||
|
state: present
|
||||||
|
regexp: '^#?\s*%sudo'
|
||||||
|
line: '%sudo ALL=(ALL) ALL'
|
||||||
|
validate: visudo -cf %s
|
||||||
|
vars:
|
||||||
|
files:
|
||||||
|
- /etc/sudoers
|
||||||
|
- /usr/local/etc/sudoers # e.g. FreeBSD
|
||||||
|
|
||||||
|
- name: 'Add sudoers user to sudo group'
|
||||||
|
user:
|
||||||
|
name: "{{ item }}"
|
||||||
|
groups: sudo
|
||||||
|
append: yes
|
||||||
|
with_items: "{{ sudoers }}"
|
||||||
|
when:
|
||||||
|
- enable_sudo
|
||||||
|
- not enable_passwordless_sudo
|
||||||
|
|
||||||
- name: 'Add corresponding authorized_keys to each user'
|
- name: 'Add corresponding authorized_keys to each user'
|
||||||
authorized_key:
|
authorized_key:
|
||||||
user: "{{ item }}"
|
user: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
key: "{{ lookup('file', 'public_keys/id_{{ item }}.pub') }}"
|
key: "{{ lookup('file', 'public_keys/id_{{ item }}.pub') }}"
|
||||||
|
exclusive: "{{ authorized_keys_are_exclusive | bool }}"
|
||||||
with_items: "{{ users }}"
|
with_items: "{{ users }}"
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- name: 'Ensure that wheel group is existing'
|
- block:
|
||||||
|
- name: 'Ensure that wheel group is existing'
|
||||||
group:
|
group:
|
||||||
name: wheel
|
name: wheel
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: 'Add sudoers user to wheel group'
|
- name: 'Add sudoers user to wheel group'
|
||||||
user:
|
user:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
groups: wheel
|
groups: wheel
|
||||||
append: yes
|
append: yes
|
||||||
with_items: "{{ sudoers }}"
|
with_items: "{{ sudoers }}"
|
||||||
|
|
||||||
|
- name: 'Allow wheel group to do passwordless sudo'
|
||||||
|
lineinfile:
|
||||||
|
dest: "{{ lookup('first_found', files, errors='ignore') }}"
|
||||||
|
state: present
|
||||||
|
regexp: '^%wheel'
|
||||||
|
line: '%wheel ALL=(ALL) NOPASSWD:ALL'
|
||||||
|
validate: visudo -cf %s
|
||||||
|
vars:
|
||||||
|
files:
|
||||||
|
- /etc/sudoers
|
||||||
|
- /usr/local/etc/sudoers # e.g. FreeBSD
|
||||||
|
when:
|
||||||
|
- enable_sudo
|
||||||
|
- enable_passwordless_sudo
|
||||||
|
|
||||||
- name: Copy tmux config
|
- name: Copy tmux config
|
||||||
copy:
|
copy:
|
||||||
src: files/tmux.conf
|
src: files/tmux.conf
|
||||||
|
|
Loading…
Add table
Reference in a new issue