This commit is contained in:
Alex 2023-11-10 17:23:54 +00:00
parent 8eaabf9544
commit 70a98b6973
39 changed files with 561 additions and 0 deletions

38
apache-config/README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for apache-config

View File

@ -0,0 +1,2 @@
---
# handlers file for apache-config

View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -0,0 +1,12 @@
---
# tasks file for apache-config
- name: "Apache configuration"
template:
src: "inventaire.conf.j2"
# apache_conf_d pointe vers la conf apache
dest: "/etc/httpd/conf.d/inventaire.conf"
owner: "apache"
group: "apache"
# En cas de changement, redémarrage dapache
notify: [ "apache restart" ]

View File

@ -0,0 +1,8 @@
Alias /inventaire /var/www/html/inventory
# Donne des droits daccès à tout le monde
# une ligne en plus
<Directory /var/www/html/inventory/>
Order Allow,Deny
Allow from All
</Directory>

View File

@ -0,0 +1,2 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- apache-config

View File

@ -0,0 +1,2 @@
---
# vars file for apache-config

38
apache-galaxy/README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for apache-galaxy

View File

@ -0,0 +1,7 @@
---
# handlers file for apache-galaxy
- name: "apache restart"
service:
name: "httpd"
state: "restarted"

View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -0,0 +1,11 @@
---
- name: "apache installation"
dnf:
name: "httpd"
state: "present"
- name: "apache service activation"
service:
name: "httpd"
state: "started"
enabled: yes

View File

@ -0,0 +1,2 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- apache-galaxy

View File

@ -0,0 +1,2 @@
---
# vars file for apache-galaxy

6
install-apache-role.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: "Apache installation"
hosts: 1-1.practice-k8s.cloud
roles:
- role: "apache-galaxy"
- role: "apache-config"

View File

@ -4,3 +4,8 @@
#[all:vars]
#ansible_ssh_user=root
[apache]
1-1.practice-k8s.cloud
[mysql]
1-2.practice-k8s.cloud

6
mediawiki/dig.yml Normal file
View File

@ -0,0 +1,6 @@
- name: Dig
hosts: localhost
tasks:
- name: bbabab
debug:
var: "{{ lookup('dig', groups['apache'][0]) }}"

View File

@ -0,0 +1,5 @@
---
- name: "Installation apache"
hosts: apache
roles:
- role: "apache"

View File

@ -0,0 +1,14 @@
- name: "MediaWiki db configuration"
hosts: mysql
gather_facts: no
tags: [ "mariadb", "mysql" ]
roles:
- role: "mediawiki/mariadb"
- name: "MediaWiki apache configuration"
hosts: apache
tags: "apache"
gather_facts: no
roles:
- role: "mediawiki/configuration"

View File

@ -0,0 +1,8 @@
---
- name: "MediaWiki db configuration"
hosts: mysql
gather_facts: no
roles:
- role: "mediawiki/mariadb"

View File

@ -0,0 +1,5 @@
---
- name: "MariaDB installation"
hosts: mysql
roles:
- role: "mariadb"

View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -0,0 +1,2 @@
---
# defaults file for apache-galaxy

View File

@ -0,0 +1,7 @@
---
# handlers file for apache-galaxy
- name: "apache restart"
service:
name: "httpd"
state: "restarted"

View File

@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -0,0 +1,15 @@
---
- name: "apache installation"
dnf:
name: "httpd"
state: "present"
- name: "apache service activation"
service:
name: "httpd"
state: "started"
enabled: yes
- name: "install php7 packages"
include_tasks: "php7-install.yml"
when: php_install|default(False)|bool

View File

@ -0,0 +1,26 @@
- name: "epel activation"
dnf:
name: "epel-release"
state: present
- name: Install epel repo.
dnf:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm"
state: present
- name: "remi repo activation"
dnf:
name: "https://rpms.remirepo.net/enterprise/remi-release-9.rpm"
state: present
disable_gpg_check: true
- name: "Active php7.4.3 remi module"
command: dnf module enable php:remi-7.4 -y
- name: "install php7.4 packages"
dnf:
name: "php,php-mysqlnd,php-xml,php-mbstring,php-mcrypt,php-gd,php-intl"
state: latest
enablerepo: "remi-php7.4"
changed_when: true # We need to restart apache
notify: [ "apache restart" ]

View File

@ -0,0 +1,2 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- apache-galaxy

View File

@ -0,0 +1,2 @@
---
# vars file for apache-galaxy

View File

@ -0,0 +1,10 @@
- name: "mariadb-server installation"
package:
name: "mariadb-server,python3-PyMySQL"
state: "installed"
- name: "start mariadb service"
service:
name: "mariadb"
state: "started"
enabled: yes

View File

@ -0,0 +1,26 @@
# Default schema
mediawiki_db_name: "mediawiki"
# Default user for mediawiki
mediawiki_db_user: "mediawiki"
mediawiki_db_password: "mediawiki"
# root MariaDB
mysql_root_password: "sdsdsklmskd45sqSS"
# default mediawiki administrator
mediawiki_admin_user: "admin"
mediawiki_admin_password: "@adm1n@adm1n"
mediawiki_name: "mediawiki"
mediawiki_title: "ELS"
mediawiki_directory: "/var/www/html/{{mediawiki_name}}"
mediawiki_maintenance_directory: "{{mediawiki_directory}}/maintenance"
# default database host: first machine from group mysql
mediawiki_db_host: "{{groups.mysql.0}}"
mediawiki_archive_url: "https://releases.wikimedia.org/mediawiki/1.38/mediawiki-core-1.38.3.tar.gz"
mediawiki_skins_url: "https://extdist.wmflabs.org/dist/skins/MonoBook-REL1_38-afefe70.tar.gz"

View File

@ -0,0 +1,4 @@
dependencies:
- role: "mediawiki/common"

View File

@ -0,0 +1,57 @@
- name: "mediawiki directory"
file:
path: "{{mediawiki_directory}}"
owner: "apache"
group: "apache"
state: directory
- name: "uncompress mediawiki archive"
unarchive:
src: "{{mediawiki_archive_url}}"
dest: "{{mediawiki_directory}}"
owner: "apache"
group: "apache"
# unpack an archive which already exists on the targe
remote_src: yes
# remove mediawiki-1.xx.x/ from path
extra_opts: --transform=s/mediawiki-[0-9\.]*\///
- name: "mediawiki configuration"
become: yes
become_user: "apache"
args:
creates: "{{mediawiki_directory}}/LocalSettings.php"
chdir: "{{mediawiki_maintenance_directory}}"
command:
php install.php --scriptpath /{{mediawiki_name}}
--dbname mediawiki --lang fr
--dbuser {{mediawiki_db_user}}
--dbpass {{mediawiki_db_password}}
--pass {{mediawiki_admin_password}}
--dbserver {{mediawiki_db_host}}
{{mediawiki_title}} {{mediawiki_admin_user}}
- name: "uncompress mediawiki skins"
unarchive:
src: "{{mediawiki_skins_url}}"
dest: "{{mediawiki_directory}}/skins"
owner: "apache"
group: "apache"
# unpack an archive which already exists on the targe
remote_src: yes
- name: "ajuste LocalSettings.php skins"
ansible.builtin.lineinfile:
path: "{{mediawiki_directory}}/LocalSettings.php"
line: wfLoadSkin( 'MonoBook' );
- name: "ajuste LocalSettings.php Server"
ansible.builtin.lineinfile:
path: "{{mediawiki_directory}}/LocalSettings.php"
search_string: '$wgServer'
line: $wgServer = "http://{{inventory_hostname}}";
- name: "ajuste LocalSettings.php Skins"
ansible.builtin.lineinfile:
path: "{{mediawiki_directory}}/LocalSettings.php"
search_string: 'wgDefaultSkin'
line: $wgDefaultSkin = "MonoBook";

View File

@ -0,0 +1,3 @@
dependencies:
- role: "mediawiki/common"

View File

@ -0,0 +1,21 @@
- name: Update MySQL root password for localhost root account (5.7.x).
ansible.builtin.shell: >
mysql -NBe 'SET PASSWORD FOR "root"@"localhost" = PASSWORD("{{ mysql_root_password }}"); FLUSH PRIVILEGES;'
- name: "mediawiki database"
community.mysql.mysql_db:
name: "{{mediawiki_db_name}}"
login_user: root
login_password: "{{ mysql_root_password }}"
state: present
- name: "mediawiki user+privileges"
mysql_user:
name: "{{mediawiki_db_user}}"
password: "{{mediawiki_db_password}}"
priv: "{{mediawiki_db_name}}.*:ALL"
host: "{{item}}"
login_user: root
login_password: "{{ mysql_root_password }}"
state: present
with_items: "{{ lookup('dig', groups['apache'][0]) }}"