new file: README.md

new file:   files/file.pub
	modified:   tasks/main.yml
main
Davo 3 years ago
parent bf8dcd4bde
commit 6ed3cf34ac
  1. 42
      README.md
  2. 1
      files/file.pub
  3. 9
      tasks/main.yml

@ -0,0 +1,42 @@
Ansible role for deploy basic packages and services. You can add custom services or packages via variables bellow.
This role is developed with Ansible 2.9.6 and tested on Ubuntu 20.04 LTS.
## Role Variables
| Variable | Required | Default | Comments |
| -------- | -------- | ------- | -------- |
| `additional_pkgs` | No | `{}` | Add aditional packages while using this role |
| `additional_services` | No | `{}` | Add aditional services while using this role |
| `sshd_username` | No | `root` | Define SSH user. MUST BE created on target system. |
| `sshd_key_file_name` | No | `key.pub` | Define SSH public key file name in this role. (files/key.pub) |
| `sshd_service_state` | No | `started` | Set SSH service state, started, enabled or disabled. |
| `sshd_service_enabled` | No | `yes` | Enable SSH service on system boot. |
| `additional_services_state` | No | `started` | Set additional service state, started, enabled or disabled. |
| `sshd_service_enabled` | No | `yes` | Enable additional service on system boot. |
## Requirements
Ansible.posix collection
To install it, use the following command:
```yaml
ansible-galaxy collection install ansible.posix
```
## Install basic packages and services with default settings
```yaml
roles:
- sw-basic
```
## Install basic packages and services with some custom variables
```yaml
roles:
- sw-basic
vars:
- sshd_key_file_name:
- newfilename.pub
```

@ -0,0 +1 @@
#your public key paste here

@ -19,7 +19,7 @@
name: "{{ item }}"
state: present
update_cache: yes
with_item: "{{ additional_pkgs }}"
with_items: "{{ additional_pkgs }}"
when: additional_pkgs is defined
- name: sw-basic | 3. Install additional services if defined
@ -27,7 +27,7 @@
name: "{{ item }}"
state: present
update_cache: yes
with_item: "{{ additional_services }}"
with_items: "{{ additional_services }}"
when: additional_services is defined
- name: sw-basic | 4. Add ssh public key file
@ -46,8 +46,7 @@
- name: sw-basic | 6. Start and enable openssh-server service
ansible.builtin.service:
name:
- openssh-server
name: sshd
state: "{{ sshd_service_state }}"
enabled: "{{ sshd_service_enabled }}"
@ -56,4 +55,4 @@
name: "{{ item }}"
state: "{{ additional_services_state }}"
enabled: "{{ additional_services_enabled }}"
with_item: "{{ additional_services }}"
with_items: "{{ additional_services }}"

Loading…
Cancel
Save