Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
@ -0,0 +1,2 @@ |
|||||||
|
[defaults] |
||||||
|
vault_password_file = vault-password |
@ -0,0 +1,7 @@ |
|||||||
|
$ANSIBLE_VAULT;1.1;AES256 |
||||||
|
33366532393138353666653365633234396238316366613234383661316466323333376565366333 |
||||||
|
3830646663633362313234656439663962323666633935350a393632336239343963626135623962 |
||||||
|
34363931383263346663636235656236653762346561366536383630356263616565643365336138 |
||||||
|
3264376566383861650a643261343935306564646165333831666530643231303430346134653836 |
||||||
|
32623163396533373735616534313536646261633630346562356139353230326161336561613739 |
||||||
|
3132613930623633613437633665653361316566666465313338 |
@ -0,0 +1,5 @@ |
|||||||
|
DB_NAME: wordpress_db |
||||||
|
DB_USER_NAME: admin |
||||||
|
DB_USER_PASSWORD: admin |
||||||
|
DB_HOST: "{{ hostvars['ansible-2']['ansible_host'] }}" |
||||||
|
WEB_HOST: "{{ hostvars['ansible-1']['ansible_host'] }}" |
@ -0,0 +1,23 @@ |
|||||||
|
ansible-1 ansible_host=192.168.56.52 |
||||||
|
ansible-2 ansible_host=192.168.56.54 |
||||||
|
ansible-3 ansible_host=192.168.56.56 |
||||||
|
ansible-4 ansible_host=192.168.56.58 ansible_user=root |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[centos] |
||||||
|
ansible-1 |
||||||
|
ansible-2 |
||||||
|
ansible-3 |
||||||
|
|
||||||
|
[debian] |
||||||
|
ansible-4 |
||||||
|
|
||||||
|
[tous:children] |
||||||
|
centos |
||||||
|
debian |
||||||
|
|
||||||
|
[wordpress] |
||||||
|
ansible-1 |
||||||
|
ansible-2 |
||||||
|
|
@ -0,0 +1,5 @@ |
|||||||
|
- hosts: ansible-3 |
||||||
|
tasks: |
||||||
|
- name: Display secure password |
||||||
|
debug: |
||||||
|
msg: "Robert's password is: {{ vault_robert_password }}" |
@ -0,0 +1,9 @@ |
|||||||
|
- hosts: ansible-2 |
||||||
|
roles: |
||||||
|
- role: postgre |
||||||
|
|
||||||
|
|
||||||
|
- hosts: ansible-1 |
||||||
|
roles: |
||||||
|
- role: apache |
||||||
|
- role: wordpress |
@ -0,0 +1,14 @@ |
|||||||
|
- name: create a new database |
||||||
|
mysql_db: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
name: '{{ DB_NAME }}' |
||||||
|
state: present |
||||||
|
|
||||||
|
- name: create a new user in database |
||||||
|
mysql_user: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
name: '{{ DB_USER_NAME }}' |
||||||
|
password: '{{ DB_USER_PASSWORD }}' |
||||||
|
priv: '{{ DB_NAME }}.*:ALL' |
||||||
|
host: '{{ DB_HOST }}' |
||||||
|
state: present |
@ -0,0 +1,28 @@ |
|||||||
|
- name: create a new database |
||||||
|
become: yes |
||||||
|
become_user: postgres |
||||||
|
postgresql_db: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
name: '{{ DB_NAME }}' |
||||||
|
state: present |
||||||
|
|
||||||
|
|
||||||
|
- name: create a new user in database |
||||||
|
become: yes |
||||||
|
become_user: postgres |
||||||
|
postgresql_user: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
db: '{{ DB_NAME }}' |
||||||
|
name: '{{ DB_USER_NAME }}' |
||||||
|
password: '{{ DB_USER_PASSWORD }}' |
||||||
|
priv: ALL |
||||||
|
expires: infinity |
||||||
|
|
||||||
|
# - name: grant all privileges |
||||||
|
# become: yes |
||||||
|
# become_user: postgres |
||||||
|
# postgresql_privs: |
||||||
|
# db: "{{ 'DB_NAME' }}" |
||||||
|
# privs: ALL |
||||||
|
# type: database |
||||||
|
# role: |
@ -0,0 +1,32 @@ |
|||||||
|
|
||||||
|
- name: Create wordpress configuration file |
||||||
|
copy: |
||||||
|
src: /var/www/html/wordpress/wp-config-sample.php |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
remote_src: yes |
||||||
|
|
||||||
|
- name: Wordpress conf, db name |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'database_name_here' |
||||||
|
replace: '{{ DB_NAME }}' |
||||||
|
|
||||||
|
|
||||||
|
- name: Wordpress conf, db username |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'username_here' |
||||||
|
replace: '{{ DB_USER_NAME }}' |
||||||
|
|
||||||
|
- name: Wordpress conf, db passwd |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'password_here' |
||||||
|
replace: '{{ DB_USER_PASSWORD }}' |
||||||
|
|
||||||
|
- name: Wordpress conf, db host |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'localhost' |
||||||
|
replace: '192.168.56.54' |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
- hosts: ansible-1 |
||||||
|
tasks: |
||||||
|
- name: Install and launch httpd |
||||||
|
yum: |
||||||
|
name: httpd |
||||||
|
state: present |
||||||
|
update_cache: yes |
||||||
|
|
||||||
|
- name: Set https systemctl enable |
||||||
|
service: |
||||||
|
name: httpd |
||||||
|
state: started |
||||||
|
enabled: yes |
||||||
|
|
||||||
|
- name: Copy static web page |
||||||
|
copy: |
||||||
|
src: index.html |
||||||
|
dest: /var/www/html/index.html |
||||||
|
mode: 0444 |
||||||
|
|
||||||
|
- name: Configure firewalld |
||||||
|
firewalld: |
||||||
|
service: http |
||||||
|
permanent: yes |
||||||
|
state: enabled |
||||||
|
immediate: yes |
@ -0,0 +1,115 @@ |
|||||||
|
- hosts: ansible-2 |
||||||
|
tasks: |
||||||
|
- name: install mariadb-server # DONE |
||||||
|
yum: |
||||||
|
name: |
||||||
|
- MySQL-python |
||||||
|
- mariadb-server |
||||||
|
- python3-pip |
||||||
|
- python3 |
||||||
|
- firewalld |
||||||
|
state: present |
||||||
|
update_cache: yes |
||||||
|
|
||||||
|
# - name: Install pymysql |
||||||
|
# pip: |
||||||
|
# name: PyMySQL |
||||||
|
# state: present |
||||||
|
# executable: pip3 |
||||||
|
|
||||||
|
- name: create a new database #DONE |
||||||
|
mysql_db: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
name: wordpress_db |
||||||
|
state: present |
||||||
|
|
||||||
|
- name: create a new user in database wordpress_db #DONE |
||||||
|
mysql_user: |
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock |
||||||
|
name: admin |
||||||
|
password: admin |
||||||
|
priv: 'wordpress_db.*:ALL' |
||||||
|
host: 192.168.56.52 |
||||||
|
state: present |
||||||
|
|
||||||
|
- name: configure firewalld # DONE |
||||||
|
firewalld: |
||||||
|
service: mysql |
||||||
|
permanent: true |
||||||
|
state: enabled |
||||||
|
immediate: yes |
||||||
|
|
||||||
|
|
||||||
|
- hosts: ansible-1 |
||||||
|
tasks: |
||||||
|
- name: Install https, php, php-mysqlnd, firewalld |
||||||
|
yum: |
||||||
|
name: |
||||||
|
- httpd |
||||||
|
- php |
||||||
|
- php-mysqlnd |
||||||
|
- firewalld |
||||||
|
- php-fpm |
||||||
|
state: present |
||||||
|
update_cache: yes |
||||||
|
|
||||||
|
- name: Enable systemctl service installed |
||||||
|
service: |
||||||
|
name: httpd |
||||||
|
state: started |
||||||
|
enabled: yes |
||||||
|
|
||||||
|
- name: Enable php |
||||||
|
service: |
||||||
|
name: php-fpm |
||||||
|
state: started |
||||||
|
enabled: yes |
||||||
|
|
||||||
|
- name: Configure firewalld |
||||||
|
firewalld: |
||||||
|
service: http |
||||||
|
permanent: yes |
||||||
|
state: enabled |
||||||
|
immediate: yes |
||||||
|
|
||||||
|
- name: Install wordpress 5.0.8 |
||||||
|
unarchive: |
||||||
|
src: https://wordpress.org/latest.tar.gz |
||||||
|
dest: /var/www/html/ |
||||||
|
remote_src: yes |
||||||
|
|
||||||
|
- name: Create wordpress configuration file |
||||||
|
copy: |
||||||
|
src: /var/www/html/wordpress/wp-config-sample.php |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
remote_src: yes |
||||||
|
|
||||||
|
- name: Wordpress conf, db name |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'database_name_here' |
||||||
|
replace: wordpress_db |
||||||
|
|
||||||
|
|
||||||
|
- name: Wordpress conf, db username |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'username_here' |
||||||
|
replace: admin |
||||||
|
|
||||||
|
- name: Wordpress conf, db passwd |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'password_here' |
||||||
|
replace: admin |
||||||
|
|
||||||
|
- name: Wordpress conf, db host |
||||||
|
replace: |
||||||
|
dest: /var/www/html/wordpress/wp-config.php |
||||||
|
regexp: 'localhost' |
||||||
|
replace: 192.168.156.54 |
||||||
|
|
||||||
|
- name: restart httpd service |
||||||
|
service: |
||||||
|
name: httpd |
||||||
|
state: restarted |
@ -0,0 +1,10 @@ |
|||||||
|
- hosts: all |
||||||
|
tasks: |
||||||
|
- name: Get user id |
||||||
|
command: id |
||||||
|
register: user_id |
||||||
|
|
||||||
|
- name: Display user id |
||||||
|
ansible.builtin.debug: |
||||||
|
var: user_id.stdout |
||||||
|
|