Installation local depuis un script bash.
This commit is contained in:
parent
6bcdb51419
commit
28e86d1f21
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
/hosts.ini
|
||||
/deploy.pub
|
||||
@ -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
|
||||
```
|
||||
|
||||
@ -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'
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
|
||||
- hosts: web
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
|
||||
@ -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"
|
||||
|
||||
18
setup.sh
Normal file
18
setup.sh
Normal 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)"
|
||||
Loading…
x
Reference in New Issue
Block a user