diff --git a/.gitignore b/.gitignore index 41173c0..9c595d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -*.retry .idea /secret +/ansible.cfg \ No newline at end of file diff --git a/ansible.cfg b/ansible.cfg.example similarity index 54% rename from ansible.cfg rename to ansible.cfg.example index dc6f990..94fdd60 100644 --- a/ansible.cfg +++ b/ansible.cfg.example @@ -1,3 +1,3 @@ [defaults] inventory=./hosts -group_vars=./group_vars +group_vars=./group_vars \ No newline at end of file diff --git a/envs/lxc/server/lxc.env.example b/envs/lxc/server/lxc.env.example new file mode 100644 index 0000000..3ff9fb9 --- /dev/null +++ b/envs/lxc/server/lxc.env.example @@ -0,0 +1,13 @@ +SERVER=proxmox_host + +LXC_HOST=project_lxc_container + +PLAYBOOK=nginx-site + +# That is a project name and name of the HOME USER +# @see group_vars/all.yml +SITE_NAME=project_name + +DOMAIN_NAME=project_domain_name + +DATABASE_NAME=project_name \ No newline at end of file diff --git a/group_vars/all.yml b/group_vars/all.yml index 1eb9c2a..df306a7 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -8,6 +8,5 @@ keyring__keyserver: hkp://keyserver.ubuntu.com:80 secret__levels: '.' -site_name: '{{ initial_site_name | d(lxc_host) }}' home_user: '{{ (ansible_user != "root") | ternary(ansible_user, site_name) }}' ... diff --git a/run-lxc-playbook.sh b/run-lxc-playbook.sh index ee41679..77cb5db 100755 --- a/run-lxc-playbook.sh +++ b/run-lxc-playbook.sh @@ -1,59 +1,58 @@ #!/bin/bash -SERVER=$1 -LXC_HOST=$2 -PLAYBOOK=$3 - -while [[ "$#" -gt 0 ]]; do - case $1 in - -f|--force) force=1; shift ;; - esac - shift -done +source $1 usage() { - echo "Usage: run-lxc-playbook.sh server lxc_host playbook" - echo "server - main proxmox server IP address and lxc_host that the name of lxc container" - echo "lxc_host - name of lxc container" - echo "playbook - playbook file" + echo "Usage: run-lxc-playbook.sh path/to/env" } if [[ -z "$SERVER" ]]; then - echo "You must defined SERVER as first argument" + echo "You must defined SERVER" usage exit 1 fi if [[ -z "$LXC_HOST" ]]; then - echo "You must defined LXC_HOST as second argument" + echo "You must defined LXC_HOST" usage exit 1 fi if [[ -z "$PLAYBOOK" ]]; then - echo "You must defined PLAYBOOK as third argument" + echo "You must defined PLAYBOOK" + usage + exit 1 +fi + +PLAYBOOK_FILEPATH="playbooks/$PLAYBOOK.yml" +if [[ ! -f "$PLAYBOOK_FILEPATH" ]]; then + echo "Playbook file is not exists: $PLAYBOOK_FILEPATH" + usage + exit 1 +fi + +if [[ -z "$SITE_NAME" ]]; then + echo "You must defined SITE_NAME" usage exit 1 fi -if [[ ! -f "$PLAYBOOK" ]]; then - echo "Playbook file is not exists: $PLAYBOOK" +if [[ -z "$DOMAIN_NAME" ]]; then + echo "You must defined DOMAIN_NAME" usage exit 1 fi -COMMAND=$(cat <