Playbook pour tomcat et mariadb
This commit is contained in:
parent
50574192c4
commit
d0ed7df887
3
ap34prod/hosts
Normal file
3
ap34prod/hosts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[local]
|
||||||
|
localhost
|
||||||
|
127.0.0.1
|
@ -10,4 +10,4 @@
|
|||||||
ui_admin_username: admin # User who can access bpth manager and admin UI sections
|
ui_admin_username: admin # User who can access bpth manager and admin UI sections
|
||||||
ui_admin_pass: root # UI admin password
|
ui_admin_pass: root # UI admin password
|
||||||
roles:
|
roles:
|
||||||
- tomcat
|
- ppebase
|
9
ap34prod/ppedb.yml
Normal file
9
ap34prod/ppedb.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: MariaDB deployment playbook
|
||||||
|
hosts: all
|
||||||
|
become: yes
|
||||||
|
become_method: sudo
|
||||||
|
remote_user: root
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- ppedb
|
@ -72,3 +72,25 @@
|
|||||||
- name: Redemarrer le service tomcat (3)
|
- name: Redemarrer le service tomcat (3)
|
||||||
local_action: command sh /usr/share/tomcat/apache-tomcat-10.0.13/bin/catalina.sh start
|
local_action: command sh /usr/share/tomcat/apache-tomcat-10.0.13/bin/catalina.sh start
|
||||||
|
|
||||||
|
|
||||||
|
- name: on installe java
|
||||||
|
apt:
|
||||||
|
name: default-jdk
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: on installe les paquets de MariaDB
|
||||||
|
apt:
|
||||||
|
name: mariadb-server
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: on installe Python3
|
||||||
|
apt:
|
||||||
|
name: python3-pymysql
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: on lance MariaDB
|
||||||
|
service:
|
||||||
|
name: mysql
|
||||||
|
state: started
|
||||||
|
|
20
ap34prod/roles/ppedb/tasks/main.yml
Executable file
20
ap34prod/roles/ppedb/tasks/main.yml
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
- name: on lance MariaDB
|
||||||
|
service:
|
||||||
|
name: mysql
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: creation de la BDD sdis29
|
||||||
|
mysql_db:
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
name: sdis29
|
||||||
|
#login_user: adminBDsdis
|
||||||
|
#login_password: mdpBDsdis
|
||||||
|
#login_host: localhost
|
||||||
|
|
||||||
|
- name: creation de l'utilisateur slam
|
||||||
|
mysql_user:
|
||||||
|
name: slam
|
||||||
|
password: Azerty1+
|
||||||
|
priv: '*.*:ALL,GRANT'
|
||||||
|
state: present
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
roles:
|
|
||||||
- bdd
|
|
@ -1 +0,0 @@
|
|||||||
[localhost]
|
|
@ -1 +0,0 @@
|
|||||||
localhost
|
|
@ -1,39 +0,0 @@
|
|||||||
- name: update
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: installer MariaDB Serveur
|
|
||||||
apt:
|
|
||||||
name: mariadb-server
|
|
||||||
state: latest
|
|
||||||
|
|
||||||
- name: installer mariadbclient
|
|
||||||
apt:
|
|
||||||
name: mariadb-client
|
|
||||||
state: latest
|
|
||||||
|
|
||||||
- name: installer python
|
|
||||||
apt:
|
|
||||||
name: python
|
|
||||||
state: latest
|
|
||||||
|
|
||||||
- name: demarrer mysql
|
|
||||||
service:
|
|
||||||
name: mysqld
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
|
|
||||||
- name: creer la bdd
|
|
||||||
community.mysql.mysql_db:
|
|
||||||
name:
|
|
||||||
- sdis29
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: creer l'utilisateur
|
|
||||||
mysql_user:
|
|
||||||
name: slam
|
|
||||||
password: Azerty1+
|
|
||||||
priv: *.*:ALL
|
|
||||||
host: 127.0.0.1
|
|
||||||
become: yes
|
|
@ -1,2 +0,0 @@
|
|||||||
tomcat_archive_url: http://depl/store/apache-tomcat-10.0.13.tar.gz
|
|
||||||
tomcat_archive_dest: /usr/share/tomcat/apache-tomcat-10.0.13.tar.gz
|
|
@ -1,100 +0,0 @@
|
|||||||
- name: on s'assure que le systeme supporte l'https
|
|
||||||
stat:
|
|
||||||
path: /usr/lib/apt/methods/https
|
|
||||||
register: apt_https_transport
|
|
||||||
|
|
||||||
- name: installer apt https transport
|
|
||||||
apt:
|
|
||||||
name: "apt-transport-https"
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
when: not apt_https_transport.stat.exists
|
|
||||||
|
|
||||||
- name: Install basic packages
|
|
||||||
package:
|
|
||||||
name: ['vim','aptitude','bash-completion','tmux','tree','htop','wget','unzip','curl','git','python']
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: installer JDK
|
|
||||||
apt:
|
|
||||||
name: openjdk-11-jdk
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: creer le repertoire /opt/tomcat
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: creer le groupe tomcat
|
|
||||||
group:
|
|
||||||
name: tomcat
|
|
||||||
|
|
||||||
- name: creer l'utilisateur tomcat
|
|
||||||
user:
|
|
||||||
name: tomcat
|
|
||||||
group: tomcat
|
|
||||||
home: /user/share/tomcat
|
|
||||||
createhome: no
|
|
||||||
|
|
||||||
- name: installer TomCat
|
|
||||||
unarchive:
|
|
||||||
src: http://depl/store/apache-tomcat-10.0.13.tar.gz
|
|
||||||
dest: /opt/tomcat
|
|
||||||
remote_src: yes
|
|
||||||
|
|
||||||
- name: Change ownership
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
owner: tomcat
|
|
||||||
group: tomcat
|
|
||||||
mode: "u+rwx,g+rx,o=rx"
|
|
||||||
recurse: yes
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Create a tomcat directory
|
|
||||||
file:
|
|
||||||
path: /usr/share/tomcat
|
|
||||||
state: directory
|
|
||||||
owner: tomcat
|
|
||||||
group: tomcat
|
|
||||||
|
|
||||||
- name: Extract tomcat archive
|
|
||||||
unarchive:
|
|
||||||
src: /opt/tomcat/apache-tomcat-10.0.13.tar.gz
|
|
||||||
dest: /usr/share/tomcat
|
|
||||||
owner: tomcat
|
|
||||||
group: tomcat
|
|
||||||
remote_src: yes
|
|
||||||
extra_opts: "--strip-components=1"
|
|
||||||
creates: /usr/share/tomcat/bin
|
|
||||||
|
|
||||||
- name: Copy Tomcat service from local to remote
|
|
||||||
copy:
|
|
||||||
src: tomcat.service.j2
|
|
||||||
dest: /etc/systemd/system/
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: demarrer le service TomCat
|
|
||||||
systemd:
|
|
||||||
name: tomcat
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
daemon_reload: yes
|
|
||||||
|
|
||||||
- name: Set UI access credentials
|
|
||||||
template:
|
|
||||||
src: tomcat-users.xml.j2
|
|
||||||
dest: /usr/share/tomcat/conf/tomcat-users.xml
|
|
||||||
notify: restart tomcat
|
|
||||||
|
|
||||||
- name: Allow access to Manager and Host Manager apps from any IP
|
|
||||||
template:
|
|
||||||
src: context.xml.j2
|
|
||||||
dest: "{{ item }}"
|
|
||||||
with_items:
|
|
||||||
- /usr/share/tomcat/webapps/host-manager/META-INF/context.xml
|
|
||||||
- /usr/share/tomcat/webapps/manager/META-INF/context.xml
|
|
||||||
notify: restart tomcat
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
- name: Install basic packages
|
|
||||||
package:
|
|
||||||
name: ['vim','aptitude','bash-completion','tmux','tree','htop','wget','unzip','curl','git','python']
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: installer JDK
|
|
||||||
apt:
|
|
||||||
name: openjdk-11-jdk
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: creer le repertoire /opt/tomcat
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: creer le groupe tomcat
|
|
||||||
group:
|
|
||||||
name: tomcat
|
|
||||||
|
|
||||||
- name: creer l'utilisateur tomcat
|
|
||||||
user:
|
|
||||||
name: tomcat
|
|
||||||
group: tomcat
|
|
||||||
home: /user/share/tomcat
|
|
||||||
createhome: no
|
|
||||||
|
|
||||||
- name: installer TomCat
|
|
||||||
unarchive:
|
|
||||||
src: http://depl/store/apache-tomcat-10.0.13.tar.gz
|
|
||||||
dest: /opt/tomcat
|
|
||||||
remote_src: yes
|
|
||||||
|
|
||||||
- name: Change ownership
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
owner: tomcat
|
|
||||||
group: tomcat
|
|
||||||
mode: "u+rwx,g+rx,o=rx"
|
|
||||||
recurse: yes
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Templating Tomcat service from local to remote
|
|
||||||
template:
|
|
||||||
src: tomcat.service.j2
|
|
||||||
dest: /etc/systemd/system/
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: VRRR demarrer le service tomcat
|
|
||||||
local_action: command sh /opt/tomcat/apache-tomcat-10.0.13/bin/startup.sh
|
|
||||||
|
|
||||||
|
|
||||||
- name: Set UI access credentials
|
|
||||||
template:
|
|
||||||
src: tomcat-users.xml.j2
|
|
||||||
dest: tomcat-users.xml
|
|
||||||
notify: restart tomcat
|
|
||||||
|
|
||||||
- name: Allow access to Manager and Host Manager apps from any IP
|
|
||||||
template:
|
|
||||||
src: context.xml.j2
|
|
||||||
dest: "{{ item }}"
|
|
||||||
with_items:
|
|
||||||
- /opt/tomcat/webapps/host-manager/META-INF/context.xml
|
|
||||||
- /opt/tomcat/webapps/manager/META-INF/context.xml
|
|
||||||
notify: restart tomcat
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
- name: Install basic packages
|
|
||||||
package:
|
|
||||||
name: ['vim','aptitude','bash-completion','tmux','tree','htop','wget','unzip','curl','git','python']
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: installer JDK
|
|
||||||
apt:
|
|
||||||
name: openjdk-11-jdk
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: creer le repertoire /opt/tomcat
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: creer le groupe tomcat
|
|
||||||
group:
|
|
||||||
name: tomcat
|
|
||||||
|
|
||||||
- name: creer l'utilisateur tomcat
|
|
||||||
user:
|
|
||||||
name: tomcat
|
|
||||||
group: tomcat
|
|
||||||
home: /user/share/tomcat
|
|
||||||
createhome: no
|
|
||||||
|
|
||||||
- name: installer TomCat
|
|
||||||
unarchive:
|
|
||||||
src: http://depl/store/apache-tomcat-10.0.13.tar.gz
|
|
||||||
dest: /opt/tomcat
|
|
||||||
remote_src: yes
|
|
||||||
|
|
||||||
- name: Change ownership
|
|
||||||
file:
|
|
||||||
path: /opt/tomcat
|
|
||||||
owner: tomcat
|
|
||||||
group: tomcat
|
|
||||||
mode: "u+rwx,g+rx,o=rx"
|
|
||||||
recurse: yes
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Templating Tomcat service from local to remote
|
|
||||||
template:
|
|
||||||
src: templates/tomcat.service.j2
|
|
||||||
dest: /etc/systemd/system/tomcat.service
|
|
||||||
when: ansible_service_mgr == "systemd"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Demarrer le service tomcat
|
|
||||||
local_action: command sh /opt/tomcat/apache-tomcat-10.0.13/bin/startup.sh
|
|
||||||
|
|
||||||
|
|
||||||
- name: Set UI access credentials
|
|
||||||
template:
|
|
||||||
src: tomcat-users.xml.j2
|
|
||||||
dest: tomcat-users.xml
|
|
||||||
notify: restart tomcat
|
|
||||||
|
|
||||||
- name: Allow access to Manager and Host Manager apps from any IP
|
|
||||||
template:
|
|
||||||
src: context.xml.j2
|
|
||||||
dest: context.xml
|
|
||||||
|
|
||||||
- name: changement de la ligne dans context.xml
|
|
||||||
replace:
|
|
||||||
path: tomcat-users.xml
|
|
||||||
regexp: <user username="manager" password="root" roles="manager-gui" />
|
|
||||||
replace: <user username="tomcat" password="toor" roles="manager-gui" />
|
|
||||||
|
|
||||||
- name: Redemarrer le service tomcat (1)
|
|
||||||
local_action: command sh /opt/tomcat/apache-tomcat-10.0.13/bin/shutdown.sh
|
|
||||||
|
|
||||||
- name: Redemarrer le service tomcat (2)
|
|
||||||
local_action: command sh /opt/tomcat/apache-tomcat-10.0.13/bin/startup.sh
|
|
Loading…
x
Reference in New Issue
Block a user