Quick start guide
For users who want to try the role quickly, this guide provides an example of how to create users, install packages, and configure services.
Install the roles:
shell> ansible-galaxy install vbotka.linux_postinstall
shell> ansible-galaxy install vbotka.ansible_lib
shell> ansible-galaxy install vbotka.linux_lib
Create the playbook
playbook.ymlfor a single host srv.example.com:
shell> cat playbook.yml
1- hosts: srv.example.com
2 gather_facts: true
3 connection: ssh
4 remote_user: admin
5 become: true
6 become_user: root
7 become_method: sudo
8 roles:
9 - vbotka.linux_postinstall
Create
host_varswith customized variables:
shell> ls -1 host_vars/srv.example.com/lp-*
1host_vars/srv.example.com/lp-common.yml
2host_vars/srv.example.com/lp-users.yml
3host_vars/srv.example.com/lp-passwords.yml
4host_vars/srv.example.com/lp-packages.yml
5host_vars/srv.example.com/lp-service.yml
To speed up execution, set non-essential variables to false:
shell> cat host_vars/srv.example.com/lp-common.yml
1lp_debug: false
2lp_backup_conf: false
3lp_flavors_enable: false
Create users. Passwords will not be created (lines 4, 7). See details.
shell> cat host_vars/srv.example.com/lp-users.yml
1lp_users:
2 - name: ansible
3 shell: /bin/sh
4 disabled_password: true
5 - name: admin
6 shell: /bin/bash
7 disabled_password: true
8lp_users_groups:
9 - name: admin
10 groups: [adm, dialout]
Configure passwords. See details.
shell> cat host_vars/srv.example.com/lp-passwords.yml
1lp_passwords: true
2lp_passwordstore: true
3lp_passwordstore_create: false
4lp_passwordstore_overwrite: false
Install packages and enable autoremove:
shell> cat host_vars/srv.example.com/lp-packages.yml
1lp_packages_autoremove: true
2lp_packages_install:
3 - ansible
4 - ansible-lint
5 - ansible-tower-cli
Configure services:
shell> cat host_vars/srv.example.com/lp-service.yml
1lp_service_debug: true
2lp_service:
3 - {name: ssh, state: started, enabled: true}
Test syntax:
shell> ansible-playbook playbook.yml --syntax-check
See which variables will be included:
shell> ansible-playbook playbook.yml -t lp_debug -e lp_debug=true
Install packages:
shell> ansible-playbook playbook.yml -t lp_packages
Perform a dry-run to display diffs and variable values:
shell> ansible-playbook playbook.yml -e lp_debug=true --check --diff
Run the playbook:
shell> ansible-playbook playbook.yml
Warning
The host has not been secured by this playbook and should be used for testing only.