A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| #!/bin/sh | |
| ### Simple shell script to create Ansible role folders | |
| sub_dirs="meta tasks vars handlers templates" | |
| [ -z "$1" ] && echo "Usage: $0 your_role " && exit 1 | |
| for role in "$@"; do |
| #handlers/main.yml | |
| --- | |
| - name: Restart apache | |
| service: name=apache2 state=restarted enabled=yes | |
| tags: | |
| - apache | |
| #task/main.yml | |
| --- | |
| - name: Enable apache modules | |
| lineinfile: > |
| #!/usr/bin/env bash | |
| ANS_FILES="inventory site.yml config.yml" | |
| ANS_DIRS="group_vars host_vars roles yml" | |
| for f in ${ANS_FILES}; do | |
| echo "touch ${f}" | |
| touch ${f} | |
| done |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| import sys | |
| import re | |
| import argparse | |
| import errno | |
| import requests | |
| from bs4 import BeautifulSoup |
There are two modes when you don't want Certbot to edit your configuration:
Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.
In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.
| #!/bin/bash | |
| iface=$1 | |
| RXB=$(</sys/class/net/"$iface"/statistics/rx_bytes) | |
| TXB=$(</sys/class/net/"$iface"/statistics/tx_bytes) | |
| sleep 1 | |
| RXBN=$(</sys/class/net/"$iface"/statistics/rx_bytes) | |
| TXBN=$(</sys/class/net/"$iface"/statistics/tx_bytes) | |
| RXDIF=$(echo $((RXBN - RXB)) ) | |
| TXDIF=$(echo $((TXBN - TXB)) ) |
| # vim:ft=ansible | |
| - hosts: localhost | |
| remote_user: admin | |
| become: True | |
| become_user: root | |
| vars: | |
| nginx_root_dir: "/var/www/html" | |
| tasks: | |
| - name: Install nginx |
| <html> | |
| <head> | |
| <title>PHP Test</title> | |
| </head> | |
| <body> | |
| <?php echo '<p>Hello World</p>'; ?> | |
| </body> | |
| </html> |