add urubamba playbooks
This commit is contained in:
parent
99708799ff
commit
8d8f209d2f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
**/files/*.key.pub
|
||||||
4
urubamba/playbook-setup.yml
Normal file
4
urubamba/playbook-setup.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: Server setup
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- users
|
||||||
14
urubamba/playbook-update.yml
Normal file
14
urubamba/playbook-update.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- name: Server update
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Update all packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "*"
|
||||||
|
state: latest # noqa package-latest
|
||||||
|
register: result_update
|
||||||
|
- name: Print update result
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ result_update.stdout_lines }}"
|
||||||
|
- name: Remove dependencies that are no longer required
|
||||||
|
ansible.builtin.apt:
|
||||||
|
autoremove: true
|
||||||
2
urubamba/roles/users/defaults/main.yml
Normal file
2
urubamba/roles/users/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
sshd_config_path: /etc/ssh/sshd_config
|
||||||
0
urubamba/roles/users/files/.gitkeep
Normal file
0
urubamba/roles/users/files/.gitkeep
Normal file
5
urubamba/roles/users/handlers/main.yml
Normal file
5
urubamba/roles/users/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: "Restart ssh daemon"
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: sshd
|
||||||
|
state: restarted
|
||||||
51
urubamba/roles/users/meta/main.yml
Normal file
51
urubamba/roles/users/meta/main.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: Václav Uruba
|
||||||
|
description: create users
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: MIT
|
||||||
|
|
||||||
|
min_ansible_version: "2.1"
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
31
urubamba/roles/users/tasks/main.yml
Normal file
31
urubamba/roles/users/tasks/main.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
- name: "Create admin user accounts"
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ item.username }}"
|
||||||
|
password: "{{ item.password | password_hash('sha512') }}"
|
||||||
|
shell: /bin/bash
|
||||||
|
with_items: "{{ admin_users }}"
|
||||||
|
|
||||||
|
- name: "Add authorized keys for admin user accounts"
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: "{{ item.username }}"
|
||||||
|
key: "{{ lookup('file', 'files/' + item.username + '.key.pub') }}"
|
||||||
|
with_items: "{{ admin_users }}"
|
||||||
|
register: add_authorized_keys
|
||||||
|
|
||||||
|
- name: "Add admin user accounts to sudoers file"
|
||||||
|
community.general.sudoers:
|
||||||
|
name: "sudo-{{ item.username }}"
|
||||||
|
user: "{{ item.username }}"
|
||||||
|
nopassword: false
|
||||||
|
commands: ALL
|
||||||
|
with_items: "{{ admin_users }}"
|
||||||
|
|
||||||
|
- name: "Disable password login"
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
dest: "{{ sshd_config_path }}"
|
||||||
|
regexp: '^(#\s*)?PasswordAuthentication '
|
||||||
|
line: 'PasswordAuthentication no'
|
||||||
|
when:
|
||||||
|
- add_authorized_keys is succeeded
|
||||||
|
notify: restart sshd
|
||||||
Loading…
x
Reference in New Issue
Block a user