Installation local depuis un script bash.

This commit is contained in:
William 2022-06-21 16:18:13 +02:00
parent 6bcdb51419
commit 28e86d1f21
6 changed files with 22 additions and 31 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
/hosts.ini
/deploy.pub

View File

@ -4,13 +4,8 @@ This playbook installs webserver (Nginx, Letsencrypt, Mariadb & PHP)
## Usage ## Usage
Config Go to your server then run :
```bash
cp hosts.example.ini hosts.ini # copy config file then change values
touch deploy.pub # paste your ssh pub key for www_user
```
Then run playbook
```bash ```bash
ansible-playbook -i hosts.ini playbook.yml curl https://github.com/re-books/playbook-webserver/blob/master/setup.sh | sudo bash
``` ```

View File

@ -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'

View File

@ -1,6 +1,7 @@
--- ---
- hosts: web - hosts: localhost
connection: local
become: true become: true
pre_tasks: pre_tasks:

View File

@ -14,13 +14,6 @@
system: true system: true
state: present 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 - name: create app's directory
file: file:
path: "{{ www_home }}/apps" path: "{{ www_home }}/apps"

18
setup.sh Normal file
View File

@ -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)"