Initial commit

This commit is contained in:
2019-06-28 02:28:50 +02:00
commit 21fcd86115
107 changed files with 8346 additions and 0 deletions

21
DOC/README.ad-hoc Normal file
View File

@ -0,0 +1,21 @@
# ----
# Execute 'ad-hoc' command through ansible with extended privileges
# ---
ansibl all --become --become-method sudo --ask-become-pass -a 'whoami'
ansible all --become --become-method sudo --ask-become-pass -a 'uptime'
# - Note:
# - alternatively, you can out the following entrie into your 'ansible-cfg' file:
# -
# - [privilege_escalation]
# - become=True
# - become_method=sudo
# - become_ask_pass=True
# -
# - Now you can omit the the 'becom' flags:
# -
ansible all -a 'whoami'
ansible all -a 'uptime'

33
DOC/README.check-if-empty Normal file
View File

@ -0,0 +1,33 @@
# - Ansible List
# -
# - Python lists have a truthiness of False when empty. So you
# - can use:
# - when: <listname>
# -
# - Example:
# - root_user: {} or
# - root_user:
# - - value1
# - - value2
# -
# - Check if list 'root_user' is empty:
# - when: root_user
# - Ansible Array /Scalar
# -
# - use:
# - when <var> is defined and <var>.lenght > 0
# -
# - Example:
# - apt_lxc_host_pkgs: []
# - apt_lxc_host_pkgs:
# - - bridge-utils
# - - lxc
# - - btrfs-tools
# - - lua5.3
# -
# - Check if list 'apt_lxc_host_pkgs'' is empty:
# - when: apt_lxc_host_pkgs is defined and apt_lxc_host_pkgs.length > 0

View File

@ -0,0 +1,12 @@
handlers:
- name: "Restart sshd"
service:
name: "sshd"
state: "restarted"
- name: "Disable root login via SSH"
lineinfile:
dest: "/etc/ssh/sshd_config"
regexp: "^PermitRootLogin"
line: "PermitRootLogin no"
notify: "Restart sshd"

8
DOC/README.gather-facts Normal file
View File

@ -0,0 +1,8 @@
# ----
# Execute 'ad-hoc' command to gather available 'facts'
# ---
ansible test.mx.oopen.de -m setup
ansible test.mx.oopen.de -m setup -a "filter=*distribution*"

View File

@ -0,0 +1,44 @@
# ==========
# running command: Troubleshooting, Tips, and Tricks
# ==========
see also: https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/commands/
# ---
# - Busted Cache
# ---
# Sometimes Ansible has a tendency to hold on to variables too long, which causes
# Ansible to think that a task/operation had already been done or changed when in
# fact it didn't.
#
# A simple fix is to flush the redis cache during a code execution.
#
# This can be done like this:
#
ansible-playbook playbooks/PLAYBOOK_NAME.yml --flush-cache
# ---
# - Check for bad syntax
# ---
# One can check to see if code contains any syntax errors by running the playbook.
#
# Check for bad syntax:
#
ansible-playbook playbooks/PLAYBOOK_NAME.yml --syntax-check
# ---
# - Running a playbook in dry-run mode
# ---
# Sometimes it can be useful to see what Ansible might do, but without actually
# changing anything.
#
# One can run in dry-run mode like this:
#
ansible-playbook playbooks/PLAYBOOK_NAME.yml --check