Browse Source

* separate launch script by runner type concepts

* do not launch sudo playbook for simple server install
* use domain_name as env variable from launch script
master
dimti 11 months ago
parent
commit
958e39bce7
  1. 9
      playbooks/root-account.yml
  2. 2
      run-lxc-playbook.sh
  3. 12
      run-playbook.sh
  4. 63
      run-site-playbook.sh
  5. 1
      vars/nginx-example.yml

9
playbooks/root-account.yml

@ -1,11 +1,10 @@
---
- import_playbook: own/locales.yml
- import_playbook: debops/tzdata.yml
- import_playbook: own/allow-releaseinfo-change.yml
#- import_playbook: own/allow-releaseinfo-change.yml# Need only for debian10
- import_playbook: debops/yadm.yml
- import_playbook: debops/root_account.yml
- import_playbook: debops/sudo.yml
- name: Adding site_name project user to sudoers
import_playbook: debops/sudo.yml
when: 'runner != "normal"'
# Import all other group playbooks in this file...
...

2
run-lxc-playbook.sh

@ -42,7 +42,7 @@ if [[ ! -f "$PLAYBOOK" ]]; then
fi
COMMAND=$(cat <<EOF
ansible-playbook -e "lxc_host=$LXC_HOST" --ssh-common-args="-o ProxyCommand='ssh -W %h:%p -q root@$SERVER'" $PLAYBOOK
ansible-playbook -e "lxc_host=$LXC_HOST" -e runner=lxc --ssh-common-args="-o ProxyCommand='ssh -W %h:%p -q root@$SERVER'" $PLAYBOOK
EOF
)

12
run-vps-playbook.sh → run-playbook.sh

@ -11,9 +11,8 @@ while [[ "$#" -gt 0 ]]; do
done
usage() {
echo "Usage: run-vps-playbook.sh server playbook [site_name]"
echo "Usage: run-vps-playbook.sh server playbook"
echo "server - domain or ip address of the vps server"
echo "site_name - site name"
echo "playbook - playbook file"
}
@ -24,21 +23,16 @@ if [[ -z "$SERVER" ]]; then
fi
if [[ -z "$PLAYBOOK" ]]; then
echo "You must defined PLAYBOOK as third argument"
echo "You must defined PLAYBOOK as second argument"
usage
exit 1
fi
COMMAND=$(cat <<EOF
ansible-playbook -e "lxc_host=${SERVER}"
ansible-playbook -e "lxc_host=${SERVER} -e runner=normal"
EOF
)
if [[ -n "$SITE_NAME" ]]; then
COMMAND="${COMMAND} -e initial_site_name=${SITE_NAME}"
fi
COMMAND="${COMMAND} ${PLAYBOOK}"
if [[ -z "$force" ]]; then

63
run-site-playbook.sh

@ -0,0 +1,63 @@
#!/bin/bash
SERVER=$1
PLAYBOOK=$2
SITE_NAME=$3
DOMAIN_NAME=$4
while [[ "$#" -gt 0 ]]; do
case $1 in
-f|--force) force=1; shift ;;
esac
shift
done
usage() {
echo "Usage: run-vps-playbook.sh server playbook site_name domain_name"
echo "server - domain or ip address of the vps server"
echo "playbook - playbook file"
echo "site_name - site name, e.g. intermetiz - that is a project name used for create home directory and www directory, and database dump base file name"
echo "domain_name - domain name, e.g. intermetiz.ru"
}
if [[ -z "$SERVER" ]]; then
echo "You must defined SERVER as first argument"
usage
exit 1
fi
if [[ -z "$PLAYBOOK" ]]; then
echo "You must defined PLAYBOOK as second argument"
usage
exit 1
fi
if [[ -z "$SITE_NAME" ]]; then
echo "You must defined SITE_NAME as third argument"
usage
exit 1
fi
if [[ -z "$DOMAIN_NAME" ]]; then
echo "You must defined DOMAIN_NAME as fourth argument"
usage
exit 1
fi
COMMAND=$(cat <<EOF
ansible-playbook -e "lxc_host=${SERVER}" -e "initial_site_name=${SITE_NAME}" -e "domain_name=${DOMAIN_NAME}" -e runner=site
EOF
)
COMMAND="${COMMAND} ${PLAYBOOK}"
if [[ -z "$force" ]]; then
printf 'Launch ansible playbook:\n%s\n' "${COMMAND}"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
/bin/bash -c "${COMMAND}"
fi
else
/bin/bash -c "${COMMAND}"
fi

1
vars/nginx-example.yml

@ -1,3 +1,2 @@
domain_name: site.com
nginx_www_domain: True
nginx_www_redirect: www
Loading…
Cancel
Save