From 28e86d1f21b8128f3fac0404301f312661187930 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 21 Jun 2022 16:18:13 +0200 Subject: [PATCH] Installation local depuis un script bash. --- .gitignore | 2 -- README.md | 9 ++------- hosts.example.ini | 14 -------------- playbook.yml | 3 ++- roles/wwwuser/tasks/main.yml | 7 ------- setup.sh | 18 ++++++++++++++++++ 6 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 hosts.example.ini create mode 100644 setup.sh diff --git a/.gitignore b/.gitignore index f7926cc..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +0,0 @@ -/hosts.ini -/deploy.pub diff --git a/README.md b/README.md index 5afc8d2..b2b45a9 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,8 @@ This playbook installs webserver (Nginx, Letsencrypt, Mariadb & PHP) ## Usage -Config -```bash -cp hosts.example.ini hosts.ini # copy config file then change values -touch deploy.pub # paste your ssh pub key for www_user -``` +Go to your server then run : -Then run playbook ```bash -ansible-playbook -i hosts.ini playbook.yml +curl https://github.com/re-books/playbook-webserver/blob/master/setup.sh | sudo bash ``` diff --git a/hosts.example.ini b/hosts.example.ini deleted file mode 100644 index 7f063f1..0000000 --- a/hosts.example.ini +++ /dev/null @@ -1,14 +0,0 @@ -[web] -example.com - -[web:vars] -ansible_ssh_user=ubuntu -ansible_python_interpreter=/usr/bin/python3 - -www_user=user -www_group=group -www_home=/home/user - -mysql_root_password='password' - -php_version='8.1' diff --git a/playbook.yml b/playbook.yml index 032bb41..8db79b7 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,6 +1,7 @@ --- -- hosts: web +- hosts: localhost + connection: local become: true pre_tasks: diff --git a/roles/wwwuser/tasks/main.yml b/roles/wwwuser/tasks/main.yml index 522e427..1f485e8 100644 --- a/roles/wwwuser/tasks/main.yml +++ b/roles/wwwuser/tasks/main.yml @@ -14,13 +14,6 @@ system: true state: present -- name: authorize ssh key to wwwuser - authorized_key: - user: "{{ www_user }}" - state: present - key: "{{ lookup('file', deploy.pub) }}" - when: ssh_key is defined - - name: create app's directory file: path: "{{ www_home }}/apps" diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..d566a8c --- /dev/null +++ b/setup.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +apt update && apt install -y ansible git + +git clone https://github.com/re-books/playbook-webserver.git + +cd playbook-webserver || exit + +echo "$(date +%s | sha256sum | base64 | head -c 32 ; echo)" > mysqlrootpassword + +chmod 600 mysqlrootpassword + +ansible-playbook -i hosts.ini playbook.yml \ + -e www_user=web \ + -e www_group=web \ + -e www_home=/home/web \ + -e php_version=8.1 \ + -e mysql_root_password="$(cat mysqlrootpassword)"