Skip to content

Instantly share code, notes, and snippets.

@partikus
Last active October 13, 2017 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save partikus/cdc7fac60abbb68ccb31749cb4697201 to your computer and use it in GitHub Desktop.
Save partikus/cdc7fac60abbb68ccb31749cb4697201 to your computer and use it in GitHub Desktop.
MyDevil.net - how to use ansible
#!/bin/bash
function printConfig {
domain=$1
echo "
error_reporting = E_ALL | E_WARNING
display_errors = off
log_errors = on
error_log = $HOME/domains/$domain/logs/error.log
"
}
DOMAINS=($(ls "$HOME/domains/"))
for domain in "${DOMAINS[@]}"
do
echo "Configure logs for: $domain";
mkdir -p "$HOME/domains/$domain/logs/" || true
touch "$HOME/domains/$domain/logs/error.log" || true
touch "$HOME/domains/$domain/.user.ini" || true
CONFIG=$(printConfig "$domain")
echo "$CONFIG" > "$HOME/domains/$domain/.user.ini"
done

To keep jenkins running in the background you can use screen.

#!/bin/bash
# jenkins.sh

if ! pgrep "jenkins" > /dev/null; then
        screen -dm java -Xms256m -Xmx512m -Dhudson.udp=-1 -Dhudson.DNSMultiCast$
fi
*/2 * * * * /usr/local/bin/bash /usr/home/YOUR_USER/domains/jenkins.example.com/jenkins.sh >/dev/null 2>&1 # Jenkins Cron

I like MyDevil solutions that's why I decided to describe few tips which I use each day

  1. Visit and configure ansible env, more here
  2. Install ansibly by pip pip install ansible
  3. Then run the following code:
#!/usr/bin/env bash
source /home/{USER_NAME}/.virtualenvs/ansible/bin/activate;
export \
  CFLAGS="-I/usr/local/include" \
  CXXFLAGS="-I/usr/local/include" \
  MAX_CONCURRENCY=1 \
  CPUCOUNT=1 \
  MKL_NUM_THREADS=1 \
  NUMEXPR_NUM_THREADS=1;
  1. Run ansible playbook using:
ansible-playbook deploy.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment