commit
aae4fe0dd8
|
@ -0,0 +1,18 @@
|
|||
# setup-host playbook
|
||||
|
||||
## Introduction
|
||||
|
||||
Playbook to perform setup of a network host. The host will need to have
|
||||
first been setup for ansible management. There will also need to be a fully
|
||||
detailed inventory file for the host.
|
||||
|
||||
The playbook will run through a number of roles to do package and user configuration,
|
||||
before finishing up with custom configurations for the specific target host.
|
||||
|
||||
This playbook can be run using the following command line;
|
||||
|
||||
ansible-playbook -l <inventory host> -i <inventory file> setup-host.yml
|
||||
|
||||
ie,
|
||||
ansible-playbook -l tnode1 -i inventory/prod.yml setup-host.yml
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
---
|
||||
###########################################################################
|
||||
#
|
||||
# This is a playbook to deploy a default configurations to a LAN host.
|
||||
#
|
||||
###########################################################################
|
||||
#
|
||||
# Playbook to perform setup of a network host. The host will need to have
|
||||
# first been setup for ansible management. There will also need to be a fully
|
||||
# detailed inventory file for the host.
|
||||
#
|
||||
########################################
|
||||
#
|
||||
# This playbook can be run using the following command line;
|
||||
#
|
||||
# ansible-playbook -l <inventory host> -i <inventory file> setup-host.yml
|
||||
#
|
||||
# ie,
|
||||
# ansible-playbook -l tnode1 -i inventory/prod.yml setup-host.yml
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
- hosts: all
|
||||
gather_facts: true
|
||||
user: root
|
||||
|
||||
vars:
|
||||
username: "{{ hostvars[inventory_hostname].user }}"
|
||||
sudoers_user: "{{ hostvars[inventory_hostname].user }}"
|
||||
userpw: "{{ hostvars[inventory_hostname].pw }}"
|
||||
homedir: "{{ hostvars[inventory_hostname].home }}"
|
||||
host_config: "{{ hostvars[inventory_hostname].host_config }}"
|
||||
guest_ip: "{{ hostvars[inventory_hostname].ansible_host }}"
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name:
|
||||
debug:
|
||||
msg: "setup-host.yml playbook"
|
||||
|
||||
roles:
|
||||
|
||||
#######################################################
|
||||
# roles applied to all guests
|
||||
- role: update_cache
|
||||
- role: upgrade_pkgs
|
||||
- role: pfetch
|
||||
|
||||
#######################################################
|
||||
- role: base_pkgs
|
||||
when: '"base_pkgs" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: create_user
|
||||
when: '"create_user" in host_config'
|
||||
- role: sudoers
|
||||
when: '"create_user" in host_config'
|
||||
- role: vim_setup
|
||||
when: '"create_user" in host_config'
|
||||
- role: bash_mods
|
||||
when: '"create_user" in host_config'
|
||||
- role: gitconfig
|
||||
when: '"create_user" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: du_backups
|
||||
when: '"du_backups" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: monitorix
|
||||
vars:
|
||||
# set variable to same value as in monitorix.yml playbook
|
||||
monitorix_pkg: "monitorix_3.15.0-izzy1_all.deb"
|
||||
when: '"monitorix" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: nagios_agent
|
||||
vars:
|
||||
agent_ip: "{{ guest_ip }}"
|
||||
when: '"nagios_agent" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: docker
|
||||
vars:
|
||||
# set variable to same value as in docker.yml playbook
|
||||
docker_compose_version: "v2.14.2"
|
||||
when: '"docker" in host_config'
|
||||
|
||||
#######################################################
|
||||
- role: k3s
|
||||
vars:
|
||||
# Calculate the number of target hosts
|
||||
numhosts: "{{ ansible_play_hosts | length }}"
|
||||
# first inventory host will be master node
|
||||
master_host: "{{ ansible_play_hosts[0] }}"
|
||||
master_ip: "{{ hostvars[master_host].ansible_host }}"
|
||||
# change k3s_user to create a non-root admin user
|
||||
k3s_user: root
|
||||
when: '"k3s" in host_config'
|
||||
|
||||
# EOF
|
Loading…
Reference in New Issue