Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Markdown lint

on:
push:
branches: [ main ]
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install pymarkdown
run: pip install pymarkdownlnt
- name: Run pymarkdown
run: pymarkdown --config .pymarkdown.json scan .
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.14
hooks:
- id: pymarkdown
args: ["scan", "."]
additional_dependencies: []
12 changes: 12 additions & 0 deletions .pymarkdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": {
"md013": {
"enabled": false
},
"md033": {
"allowed_elements": [
"br"
]
}
}
}
113 changes: 113 additions & 0 deletions Automation/Ansible-Beginner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Learning Ansible

- **Author:** nduytg
- **Version:** 0.3
- **Date:** 2017-04-12
- **Tested on:** Ubuntu 16.04

This quick-start shows how to install Ansible on Ubuntu and exercise it against
lightweight LXC containers that simulate a small fleet of hosts.

## Installation options

### Option 1: Clone from Git

```bash
sudo apt-get install git-core
cd ~
git clone https://github.com/ansible/ansible
cd ansible
git log
git submodule update --init --recursive
sudo apt-get install python-jinja2 python-paramiko python-yaml sshpass
```

Activate Ansible's development environment and confirm the binary is available.

```bash
which ansible
less ./hacking/env-setup
source ./hacking/env-setup
which ansible
ansible --version
```

### Option 2: Install from apt

```bash
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
```

## Prepare target containers with LXC

Install LXC on the control node and create a few Ubuntu containers that mimic a
small environment.

```bash
sudo apt-get update
sudo apt-get install lxc
lxc-ls --fancy
```

Create two web servers and one database server.

```bash
sudo lxc-create -n web1 -t ubuntu
sudo lxc-create -n web2 -t ubuntu
sudo lxc-create -n db1 -t ubuntu
```

List and start the containers as background services.

```bash
lxc-ls -f
sudo lxc-start -n web1 -d
sudo lxc-start -n web2 -d
sudo lxc-start -n db1 -d
```

Log into a container to satisfy Ansible's prerequisites (Python 2.x and SSH).

```bash
sudo lxc-attach -n web1
sudo apt-get install python-minimal
exit
```

Repeat for the remaining containers as needed.

## Create an inventory

Build a simple inventory that groups the LXC instances into logical roles.

```ini
# inventory
[allservers]
10.0.3.113
10.0.3.247
10.0.3.95

[web]
10.0.3.247
10.0.3.95

[database]
10.0.3.113
```

## Run ad-hoc commands

Verify connectivity and perform common administrative actions.

```bash
ansible allservers -m ping -u ubuntu -i inventory
ansible allservers -a "free -h" -u ubuntu -i inventory
ansible allservers -a "apt list --installed | grep nginx" -u ubuntu -i inventory
ansible allservers -a "apt-get update" -u root -i inventory
ansible web -a "apt-get install -y nginx" -u root -i inventory
ansible web -m service -a "name=nginx state=restarted" -u root -i inventory
```
93 changes: 0 additions & 93 deletions Automation/Ansible-Beginner.txt

This file was deleted.

47 changes: 47 additions & 0 deletions Backup/backup-rsync-crontab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Rsync Backup Managed by Cron

- **Author:** nduytg
- **Version:** 0.5
- **Date:** 2017-11-21
- **Tested on:** CentOS 7

Automate incremental backups with `rsync` and `cron`. Start with a local copy,
expand to a remote target over SSH, and finish by restarting the cron service to
apply schedule changes.

## Local dry run

```bash
sudo yum install rsync
rsync -av --dry-run --delete /home/nduytg/source/ /home/nduytg/backup/
```

## Remote dry run over SSH

```bash
sudo yum install openssh-clients rsync
rsync -av --dry-run --delete -e ssh /home/nduytg/source/ \
root@192.168.31.131:/root/backup
```

Generate SSH keys and copy the public key to the remote host to avoid
interactive password prompts when cron executes the job.

## Schedule the synchronization

```bash
sudo crontab -e
```

Example entry (run every two minutes during testing):

```cron
*/2 * * * * rsync -av --delete -e ssh /home/nduytg/source/ \
root@192.168.31.131:/root/backup > /dev/null 2>&1
```

Restart the cron daemon after editing the schedule.

```bash
sudo systemctl restart crond
```
27 changes: 0 additions & 27 deletions Backup/backup-rsync-crontab.txt

This file was deleted.

Loading