ansible-tomcat
This commit is contained in:
parent
83166e1296
commit
d6bdd0d059
BIN
SDIS29ansible/ansible/.ppebase.yml.swp
Normal file
BIN
SDIS29ansible/ansible/.ppebase.yml.swp
Normal file
Binary file not shown.
0
SDIS29ansible/ansible/.test.yml.swp
Normal file
0
SDIS29ansible/ansible/.test.yml.swp
Normal file
9
SDIS29ansible/ansible/db.yml
Normal file
9
SDIS29ansible/ansible/db.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: db playbook
|
||||||
|
hosts: all # Inventory hosts group / server to act on
|
||||||
|
become: yes # If to escalate privilege
|
||||||
|
become_method: sudo # Set become method
|
||||||
|
remote_user: root # Update username for remote server
|
||||||
|
roles:
|
||||||
|
- db
|
||||||
|
|
9
SDIS29ansible/ansible/dbdump.yml
Normal file
9
SDIS29ansible/ansible/dbdump.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: dbdump playbook
|
||||||
|
hosts: all # Inventory hosts group / server to act on
|
||||||
|
become: yes # If to escalate privilege
|
||||||
|
become_method: sudo # Set become method
|
||||||
|
remote_user: root # Update username for remote server
|
||||||
|
roles:
|
||||||
|
- dbdump
|
||||||
|
|
3
SDIS29ansible/ansible/hosts
Normal file
3
SDIS29ansible/ansible/hosts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[adm]
|
||||||
|
srvtomcat
|
||||||
|
|
1
SDIS29ansible/ansible/invent
Normal file
1
SDIS29ansible/ansible/invent
Normal file
@ -0,0 +1 @@
|
|||||||
|
srvtomcat
|
17
SDIS29ansible/ansible/roles/base/main.yml
Normal file
17
SDIS29ansible/ansible/roles/base/main.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
- name: Ensure the system can use the HTTPS transport for APT.
|
||||||
|
stat:
|
||||||
|
path: /usr/lib/apt/methods/https
|
||||||
|
register: apt_https_transport
|
||||||
|
|
||||||
|
- name: Install 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','unzi>
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
14
SDIS29ansible/ansible/roles/db/handlers/main.yml
Normal file
14
SDIS29ansible/ansible/roles/db/handlers/main.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
- name: Reload Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Restart Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Restart mysql
|
||||||
|
service:
|
||||||
|
name: mysql
|
||||||
|
state: restarted
|
60
SDIS29ansible/ansible/roles/db/tasks/main.yml
Normal file
60
SDIS29ansible/ansible/roles/db/tasks/main.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
- name: "Mise à jour du cache MYSQL"
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: "Installation de MYSQL"
|
||||||
|
apt:
|
||||||
|
name: mariadb-server
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: "Installation Python"
|
||||||
|
apt:
|
||||||
|
name: python
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: "Installation Python3-pymysql"
|
||||||
|
apt:
|
||||||
|
name: python3-pymysql
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Démarrage MYSQL"
|
||||||
|
service:
|
||||||
|
name: "mysqld"
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
- name: "Création de la BDD"
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name : "sdis29"
|
||||||
|
check_implicit_admin: yes
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
login_user: root
|
||||||
|
login_password: root
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: "Création utilisateur BDD"
|
||||||
|
mysql_user:
|
||||||
|
check_implicit_admin: yes
|
||||||
|
login_user: root
|
||||||
|
login_password: root
|
||||||
|
name: "dev"
|
||||||
|
password: "Azerty1+"
|
||||||
|
priv: "*.*:ALL,GRANT"
|
||||||
|
host: "localhost"
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
|
||||||
|
- name: copie du dump
|
||||||
|
copy:
|
||||||
|
src: ~/sauvegarde/sdis-dump.sql
|
||||||
|
dest: /tmp/
|
||||||
|
|
||||||
|
- name: "Restorer de la BDD"
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name: sdis29
|
||||||
|
state: import
|
||||||
|
target: /tmp/sdis29.sql
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
login_user: dev
|
||||||
|
login_password: Azerty1+
|
||||||
|
|
52
SDIS29ansible/ansible/roles/db/tasks/main.yml.sv
Normal file
52
SDIS29ansible/ansible/roles/db/tasks/main.yml.sv
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
- name: "[MYSQL] - update cache"
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: "[MYSQL] - install"
|
||||||
|
apt:
|
||||||
|
name: mariadb-server
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: "[Python] - install"
|
||||||
|
apt:
|
||||||
|
name: python
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: "[Python3-mysql] - install"
|
||||||
|
apt:
|
||||||
|
name: python3-pymysql
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
|
||||||
|
- name: "[MYSQL] - start mysql"
|
||||||
|
service:
|
||||||
|
name: "mysqld"
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
- name: "[MYSQL] - create database"
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name : "sdis29"
|
||||||
|
check_implicit_admin: yes
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: "[MYSQL] - create user"
|
||||||
|
mysql_user:
|
||||||
|
name: "dev"
|
||||||
|
password: "Azerty1+"
|
||||||
|
priv: "*.*:ALL"
|
||||||
|
host: "192.168.0.48"
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
|
||||||
|
|
||||||
|
- name: Copier dump
|
||||||
|
copy:
|
||||||
|
src: db-sauv.sql.gz
|
||||||
|
dest: /tmp
|
||||||
|
|
||||||
|
- name: Restorer la base de données
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name: my_db
|
||||||
|
state: import
|
||||||
|
target: /tmp/db-sauv.sql.gz
|
5
SDIS29ansible/ansible/roles/db/vars/debian.yml
Normal file
5
SDIS29ansible/ansible/roles/db/vars/debian.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
mysql_packages:
|
||||||
|
- mariadb-server
|
||||||
|
- python-mysqldb
mysql_db: "sdis29"
|
||||||
|
- mysql_user: "dev"
|
||||||
|
- mysql_password: "Azerty1+"
|
24
SDIS29ansible/ansible/roles/dbdump/tasks/main.yml
Normal file
24
SDIS29ansible/ansible/roles/dbdump/tasks/main.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#- name: dump de la base de données
|
||||||
|
# community.mysql.mysql_db:
|
||||||
|
# state: dump
|
||||||
|
# src: db-sauv.sql.gz
|
||||||
|
# dest: "/root/db/sauv/db-sauv.sql.gz"
|
||||||
|
# check_implicit_admin: yes
|
||||||
|
# login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
# login_user: "dev"
|
||||||
|
# login_password: "Azerty1+"
|
||||||
|
|
||||||
|
- name: Dump de la BDD sdis29
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
state: dump
|
||||||
|
name: sdis29
|
||||||
|
target: /tmp/sdis-dump.sql
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
login_user: "dev"
|
||||||
|
login_password: "Azerty1+"
|
||||||
|
|
||||||
|
- name: importation sur la machine local
|
||||||
|
ansible.builtin.fetch:
|
||||||
|
src: /tmp/sdis-dump.sql
|
||||||
|
dest: /root/sauvegarde/
|
||||||
|
flat: yes
|
3
SDIS29ansible/ansible/roles/tomcat/defaults/main.yml
Normal file
3
SDIS29ansible/ansible/roles/tomcat/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
tomcat_archive_url: http://depl/store/apache-tomcat-10.0.13.tar.gz
|
||||||
|
tomcat_archive_dest: /tmp/apache-tomcat-{{ tomcat_ver }}.tar.gz
|
4
SDIS29ansible/ansible/roles/tomcat/handlers/main.yml
Normal file
4
SDIS29ansible/ansible/roles/tomcat/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: restart tomcat
|
||||||
|
service:
|
||||||
|
name: tomcat
|
||||||
|
state: restarted
|
67
SDIS29ansible/ansible/roles/tomcat/tasks/main.yml
Normal file
67
SDIS29ansible/ansible/roles/tomcat/tasks/main.yml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
- name: Install Default Java (Debian/Ubuntu)
|
||||||
|
apt:
|
||||||
|
name: default-jdk
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: ajout du groupe tomcat
|
||||||
|
group:
|
||||||
|
name: tomcat
|
||||||
|
|
||||||
|
- name: ajout du tomcat user
|
||||||
|
user:
|
||||||
|
name: tomcat
|
||||||
|
group: tomcat
|
||||||
|
home: /usr/share/tomcat
|
||||||
|
createhome: no
|
||||||
|
system: yes
|
||||||
|
|
||||||
|
- name: téléchargement de Tomcat
|
||||||
|
get_url:
|
||||||
|
url: "http://depl/store/apache-tomcat-10.0.13.tar.gz"
|
||||||
|
dest: "{{ tomcat_archive_dest }}"
|
||||||
|
|
||||||
|
- name: Crée une direction pour tomcat
|
||||||
|
file:
|
||||||
|
path: /usr/share/tomcat
|
||||||
|
state: directory
|
||||||
|
owner: tomcat
|
||||||
|
group: tomcat
|
||||||
|
|
||||||
|
- name: Extraction de l'archive tomcat
|
||||||
|
unarchive:
|
||||||
|
src: "{{ tomcat_archive_dest }}"
|
||||||
|
dest: /usr/share/tomcat
|
||||||
|
owner: tomcat
|
||||||
|
group: tomcat
|
||||||
|
remote_src: yes
|
||||||
|
extra_opts: "--strip-components=1"
|
||||||
|
creates: /usr/share/tomcat/bin
|
||||||
|
|
||||||
|
- name: Copie du tomcat service file
|
||||||
|
template:
|
||||||
|
src: tomcat.service.j2
|
||||||
|
dest: /etc/systemd/system/tomcat.service
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
|
- name: démarrage et activation de tomcat
|
||||||
|
service:
|
||||||
|
daemon_reload: yes
|
||||||
|
name: tomcat
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
when: ansible_service_mgr == "systemd"
|
||||||
|
|
||||||
|
- 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
|
19
SDIS29ansible/ansible/roles/tomcat/templates/context.xml.j2
Normal file
19
SDIS29ansible/ansible/roles/tomcat/templates/context.xml.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<Context antiResourceLocking="false" privileged="true" >
|
||||||
|
</Context>
|
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
this work for additional information regarding copyright ownership.
|
||||||
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
(the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<tomcat-users xmlns="http://tomcat.apache.org/xml"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
|
||||||
|
version="1.0">
|
||||||
|
<!--
|
||||||
|
NOTE: By default, no user is included in the "manager-gui" role required
|
||||||
|
to operate the "/manager/html" web application. If you wish to use this app,
|
||||||
|
you must define such a user - the username and password are arbitrary. It is
|
||||||
|
strongly recommended that you do NOT use one of the users in the commented out
|
||||||
|
section below since they are intended for use with the examples web
|
||||||
|
application.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
NOTE: The sample user and role entries below are intended for use with the
|
||||||
|
examples web application. They are wrapped in a comment and thus are ignored
|
||||||
|
when reading this file. If you wish to configure these users for use with the
|
||||||
|
examples web application, do not forget to remove the <!.. ..> that surrounds
|
||||||
|
them. You will also need to set the passwords to something appropriate.
|
||||||
|
-->
|
||||||
|
<!-- user manager can access only manager section -->
|
||||||
|
<role rolename="manager-gui" />
|
||||||
|
<user username="{{ ui_manager_user }}" password="{{ ui_manager_pass }}" roles="manager-gui" />
|
||||||
|
|
||||||
|
<!-- user admin can access manager and admin section both -->
|
||||||
|
<role rolename="admin-gui" />
|
||||||
|
<user username="{{ ui_admin_username }}" password="{{ ui_admin_pass }}" roles="manager-gui,admin-gui" />
|
||||||
|
</tomcat-users>
|
@ -0,0 +1,22 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Tomcat
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
|
||||||
|
User=tomcat
|
||||||
|
Group=tomcat
|
||||||
|
|
||||||
|
Environment=JAVA_HOME={{ JAVA_HOME }}
|
||||||
|
Environment='JAVA_OPTS=-Djava.awt.headless=true'
|
||||||
|
|
||||||
|
Environment=CATALINA_HOME=/usr/share/tomcat
|
||||||
|
Environment=CATALINA_BASE=/usr/share/tomcat
|
||||||
|
Environment=CATALINA_PID=/usr/share/tomcat/temp/tomcat.pid
|
||||||
|
|
||||||
|
ExecStart=/usr/share/tomcat/bin/catalina.sh start
|
||||||
|
ExecStop=/usr/share/tomcat/bin/catalina.sh stop
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
2
SDIS29ansible/ansible/roles/tomcat/vars/main.yml
Normal file
2
SDIS29ansible/ansible/roles/tomcat/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
JAVA_HOME: /usr/lib/jvm/default-java
|
16
SDIS29ansible/ansible/tomcat-setup.yml
Normal file
16
SDIS29ansible/ansible/tomcat-setup.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: Tomcat deployment playbook
|
||||||
|
hosts: all # Inventory hosts group / server to act on
|
||||||
|
become: yes # If to escalate privilege
|
||||||
|
become_method: sudo # Set become method
|
||||||
|
remote_user: root # Update username for remote server
|
||||||
|
vars:
|
||||||
|
tomcat_ver: 10.0.14 # Tomcat version to install
|
||||||
|
ui_manager_user: manager # User who can access the UI manager section only
|
||||||
|
ui_manager_pass: azerty1+ # UI manager user password
|
||||||
|
ui_admin_username: admin # User who can access bpth manager and admin UI sections
|
||||||
|
ui_admin_pass: Azerty1+ # UI admin password
|
||||||
|
roles:
|
||||||
|
# - tomcat
|
||||||
|
- db
|
||||||
|
- dbdump
|
Loading…
x
Reference in New Issue
Block a user