Quick start guide
For the 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.yml
for single host srv.example.com (2)
1shell> cat playbook.yml
2- hosts: srv.example.com
3 gather_facts: true
4 connection: ssh
5 remote_user: admin
6 become: yes
7 become_user: root
8 become_method: sudo
9 roles:
10 - vbotka.linux_postinstall
Create
host_vars
with customized variables
1shell> ls -1 host_vars/srv.example.com/lp-*
2host_vars/srv.example.com/lp-common.yml
3host_vars/srv.example.com/lp-users.yml
4host_vars/srv.example.com/lp-passwords.yml
5host_vars/srv.example.com/lp-packages.yml
6host_vars/srv.example.com/lp-service.yml
To speedup the execution set some variables (2-4) to false
1shell> cat host_vars/srv.example.com/lp-common.yml
2lp_debug: false
3lp_backup_conf: false
4lp_flavors_enable: false
Create users. The passwords will not be created (5,8). See details
1shell> cat host_vars/srv.example.com/lp-users.yml
2lp_users:
3 - name: ansible
4 shell: /bin/sh
5 disabled_password: true
6 - name: admin
7 shell: /bin/bash
8 disabled_password: true
9lp_users_groups:
10 - name: admin
11 groups: [adm, dialout]
Configure passwords. See details
1shell> cat host_vars/srv.example.com/lp-passwords.yml
2lp_passwords: true
3lp_passwordstore: true
4lp_passwordstore_create: false
5lp_passwordstore_overwrite: false
Install packages and enable autoremove
1shell> cat host_vars/srv.example.com/lp-packages.yml
2lp_packages_autoremove: true
3lp_packages_install:
4 - ansible
5 - ansible-lint
6 - ansible-tower-cli
Configure services
1shell> cat host_vars/srv.example.com/lp-service.yml
2lp_service_debug: true
3lp_service:
4 - {name: ssh, state: started, enabled: true}
Test syntax
shell> ansible-playbook playbook.yml --syntax-check
See what 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
Dry-run, display differences and display variables
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.