From 70a98b6973a9e8fa2330973e8095118eb868d79a Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 10 Nov 2023 17:23:54 +0000 Subject: [PATCH] 1823 --- apache-config/README.md | 38 +++++++++++++ apache-config/defaults/main.yml | 2 + apache-config/handlers/main.yml | 2 + apache-config/meta/main.yml | 52 +++++++++++++++++ apache-config/tasks/main.yml | 12 ++++ apache-config/templates/inventaire.conf.j2 | 8 +++ apache-config/tests/inventory | 2 + apache-config/tests/test.yml | 5 ++ apache-config/vars/main.yml | 2 + apache-galaxy/README.md | 38 +++++++++++++ apache-galaxy/defaults/main.yml | 2 + apache-galaxy/handlers/main.yml | 7 +++ apache-galaxy/meta/main.yml | 52 +++++++++++++++++ apache-galaxy/tasks/main.yml | 11 ++++ apache-galaxy/tests/inventory | 2 + apache-galaxy/tests/test.yml | 5 ++ apache-galaxy/vars/main.yml | 2 + install-apache-role.yml | 6 ++ inventory.ini | 5 ++ mediawiki/dig.yml | 6 ++ mediawiki/install-apache-role-mediawiki.yml | 5 ++ .../install-mediawiki-role-mediawiki.yml | 14 +++++ mediawiki/install-mediawiki.yml | 8 +++ mediawiki/install-mysql-role-mediawiki.yml | 5 ++ mediawiki/roles/apache/README.md | 38 +++++++++++++ mediawiki/roles/apache/defaults/main.yml | 2 + mediawiki/roles/apache/handlers/main.yml | 7 +++ mediawiki/roles/apache/meta/main.yml | 52 +++++++++++++++++ mediawiki/roles/apache/tasks/main.yml | 15 +++++ mediawiki/roles/apache/tasks/php7-install.yml | 26 +++++++++ mediawiki/roles/apache/tests/inventory | 2 + mediawiki/roles/apache/tests/test.yml | 5 ++ mediawiki/roles/apache/vars/main.yml | 2 + mediawiki/roles/mariadb/tasks/main.yml | 10 ++++ .../roles/mediawiki/common/defaults/main.yml | 26 +++++++++ .../mediawiki/configuration/meta/main.yml | 4 ++ .../mediawiki/configuration/tasks/main.yml | 57 +++++++++++++++++++ .../roles/mediawiki/mariadb/meta/main.yml | 3 + .../roles/mediawiki/mariadb/tasks/main.yml | 21 +++++++ 39 files changed, 561 insertions(+) create mode 100644 apache-config/README.md create mode 100644 apache-config/defaults/main.yml create mode 100644 apache-config/handlers/main.yml create mode 100644 apache-config/meta/main.yml create mode 100644 apache-config/tasks/main.yml create mode 100644 apache-config/templates/inventaire.conf.j2 create mode 100644 apache-config/tests/inventory create mode 100644 apache-config/tests/test.yml create mode 100644 apache-config/vars/main.yml create mode 100644 apache-galaxy/README.md create mode 100644 apache-galaxy/defaults/main.yml create mode 100644 apache-galaxy/handlers/main.yml create mode 100644 apache-galaxy/meta/main.yml create mode 100644 apache-galaxy/tasks/main.yml create mode 100644 apache-galaxy/tests/inventory create mode 100644 apache-galaxy/tests/test.yml create mode 100644 apache-galaxy/vars/main.yml create mode 100644 install-apache-role.yml create mode 100644 mediawiki/dig.yml create mode 100644 mediawiki/install-apache-role-mediawiki.yml create mode 100644 mediawiki/install-mediawiki-role-mediawiki.yml create mode 100644 mediawiki/install-mediawiki.yml create mode 100644 mediawiki/install-mysql-role-mediawiki.yml create mode 100644 mediawiki/roles/apache/README.md create mode 100644 mediawiki/roles/apache/defaults/main.yml create mode 100644 mediawiki/roles/apache/handlers/main.yml create mode 100644 mediawiki/roles/apache/meta/main.yml create mode 100644 mediawiki/roles/apache/tasks/main.yml create mode 100644 mediawiki/roles/apache/tasks/php7-install.yml create mode 100644 mediawiki/roles/apache/tests/inventory create mode 100644 mediawiki/roles/apache/tests/test.yml create mode 100644 mediawiki/roles/apache/vars/main.yml create mode 100644 mediawiki/roles/mariadb/tasks/main.yml create mode 100644 mediawiki/roles/mediawiki/common/defaults/main.yml create mode 100644 mediawiki/roles/mediawiki/configuration/meta/main.yml create mode 100644 mediawiki/roles/mediawiki/configuration/tasks/main.yml create mode 100644 mediawiki/roles/mediawiki/mariadb/meta/main.yml create mode 100644 mediawiki/roles/mediawiki/mariadb/tasks/main.yml diff --git a/apache-config/README.md b/apache-config/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/apache-config/README.md @@ -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). diff --git a/apache-config/defaults/main.yml b/apache-config/defaults/main.yml new file mode 100644 index 0000000..c5fe370 --- /dev/null +++ b/apache-config/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for apache-config diff --git a/apache-config/handlers/main.yml b/apache-config/handlers/main.yml new file mode 100644 index 0000000..8e8f1c3 --- /dev/null +++ b/apache-config/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for apache-config diff --git a/apache-config/meta/main.yml b/apache-config/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/apache-config/meta/main.yml @@ -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. diff --git a/apache-config/tasks/main.yml b/apache-config/tasks/main.yml new file mode 100644 index 0000000..4e8f8a0 --- /dev/null +++ b/apache-config/tasks/main.yml @@ -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 d’apache + notify: [ "apache restart" ] diff --git a/apache-config/templates/inventaire.conf.j2 b/apache-config/templates/inventaire.conf.j2 new file mode 100644 index 0000000..756128d --- /dev/null +++ b/apache-config/templates/inventaire.conf.j2 @@ -0,0 +1,8 @@ +Alias /inventaire /var/www/html/inventory + +# Donne des droits d’accès à tout le monde +# une ligne en plus + + Order Allow,Deny + Allow from All + diff --git a/apache-config/tests/inventory b/apache-config/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/apache-config/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/apache-config/tests/test.yml b/apache-config/tests/test.yml new file mode 100644 index 0000000..869d93c --- /dev/null +++ b/apache-config/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - apache-config diff --git a/apache-config/vars/main.yml b/apache-config/vars/main.yml new file mode 100644 index 0000000..ad38ca4 --- /dev/null +++ b/apache-config/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for apache-config diff --git a/apache-galaxy/README.md b/apache-galaxy/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/apache-galaxy/README.md @@ -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). diff --git a/apache-galaxy/defaults/main.yml b/apache-galaxy/defaults/main.yml new file mode 100644 index 0000000..c514383 --- /dev/null +++ b/apache-galaxy/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for apache-galaxy diff --git a/apache-galaxy/handlers/main.yml b/apache-galaxy/handlers/main.yml new file mode 100644 index 0000000..23bd582 --- /dev/null +++ b/apache-galaxy/handlers/main.yml @@ -0,0 +1,7 @@ +--- +# handlers file for apache-galaxy + +- name: "apache restart" + service: + name: "httpd" + state: "restarted" diff --git a/apache-galaxy/meta/main.yml b/apache-galaxy/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/apache-galaxy/meta/main.yml @@ -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. diff --git a/apache-galaxy/tasks/main.yml b/apache-galaxy/tasks/main.yml new file mode 100644 index 0000000..20c6800 --- /dev/null +++ b/apache-galaxy/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: "apache installation" + dnf: + name: "httpd" + state: "present" + +- name: "apache service activation" + service: + name: "httpd" + state: "started" + enabled: yes diff --git a/apache-galaxy/tests/inventory b/apache-galaxy/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/apache-galaxy/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/apache-galaxy/tests/test.yml b/apache-galaxy/tests/test.yml new file mode 100644 index 0000000..9cd1316 --- /dev/null +++ b/apache-galaxy/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - apache-galaxy diff --git a/apache-galaxy/vars/main.yml b/apache-galaxy/vars/main.yml new file mode 100644 index 0000000..9be831f --- /dev/null +++ b/apache-galaxy/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for apache-galaxy diff --git a/install-apache-role.yml b/install-apache-role.yml new file mode 100644 index 0000000..961bdcb --- /dev/null +++ b/install-apache-role.yml @@ -0,0 +1,6 @@ +--- +- name: "Apache installation" + hosts: 1-1.practice-k8s.cloud + roles: + - role: "apache-galaxy" + - role: "apache-config" diff --git a/inventory.ini b/inventory.ini index 7f64a2e..b2073df 100644 --- a/inventory.ini +++ b/inventory.ini @@ -4,3 +4,8 @@ #[all:vars] #ansible_ssh_user=root +[apache] +1-1.practice-k8s.cloud + +[mysql] +1-2.practice-k8s.cloud diff --git a/mediawiki/dig.yml b/mediawiki/dig.yml new file mode 100644 index 0000000..548e982 --- /dev/null +++ b/mediawiki/dig.yml @@ -0,0 +1,6 @@ +- name: Dig + hosts: localhost + tasks: + - name: bbabab + debug: + var: "{{ lookup('dig', groups['apache'][0]) }}" diff --git a/mediawiki/install-apache-role-mediawiki.yml b/mediawiki/install-apache-role-mediawiki.yml new file mode 100644 index 0000000..edf68d9 --- /dev/null +++ b/mediawiki/install-apache-role-mediawiki.yml @@ -0,0 +1,5 @@ +--- +- name: "Installation apache" + hosts: apache + roles: + - role: "apache" diff --git a/mediawiki/install-mediawiki-role-mediawiki.yml b/mediawiki/install-mediawiki-role-mediawiki.yml new file mode 100644 index 0000000..529de99 --- /dev/null +++ b/mediawiki/install-mediawiki-role-mediawiki.yml @@ -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" + diff --git a/mediawiki/install-mediawiki.yml b/mediawiki/install-mediawiki.yml new file mode 100644 index 0000000..44db65b --- /dev/null +++ b/mediawiki/install-mediawiki.yml @@ -0,0 +1,8 @@ +--- +- name: "MediaWiki db configuration" + hosts: mysql + gather_facts: no + roles: + - role: "mediawiki/mariadb" + + diff --git a/mediawiki/install-mysql-role-mediawiki.yml b/mediawiki/install-mysql-role-mediawiki.yml new file mode 100644 index 0000000..5e4e2d8 --- /dev/null +++ b/mediawiki/install-mysql-role-mediawiki.yml @@ -0,0 +1,5 @@ +--- +- name: "MariaDB installation" + hosts: mysql + roles: + - role: "mariadb" diff --git a/mediawiki/roles/apache/README.md b/mediawiki/roles/apache/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/mediawiki/roles/apache/README.md @@ -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). diff --git a/mediawiki/roles/apache/defaults/main.yml b/mediawiki/roles/apache/defaults/main.yml new file mode 100644 index 0000000..c514383 --- /dev/null +++ b/mediawiki/roles/apache/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for apache-galaxy diff --git a/mediawiki/roles/apache/handlers/main.yml b/mediawiki/roles/apache/handlers/main.yml new file mode 100644 index 0000000..23bd582 --- /dev/null +++ b/mediawiki/roles/apache/handlers/main.yml @@ -0,0 +1,7 @@ +--- +# handlers file for apache-galaxy + +- name: "apache restart" + service: + name: "httpd" + state: "restarted" diff --git a/mediawiki/roles/apache/meta/main.yml b/mediawiki/roles/apache/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/mediawiki/roles/apache/meta/main.yml @@ -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. diff --git a/mediawiki/roles/apache/tasks/main.yml b/mediawiki/roles/apache/tasks/main.yml new file mode 100644 index 0000000..e1db538 --- /dev/null +++ b/mediawiki/roles/apache/tasks/main.yml @@ -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 diff --git a/mediawiki/roles/apache/tasks/php7-install.yml b/mediawiki/roles/apache/tasks/php7-install.yml new file mode 100644 index 0000000..302b10c --- /dev/null +++ b/mediawiki/roles/apache/tasks/php7-install.yml @@ -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" ] \ No newline at end of file diff --git a/mediawiki/roles/apache/tests/inventory b/mediawiki/roles/apache/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/mediawiki/roles/apache/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/mediawiki/roles/apache/tests/test.yml b/mediawiki/roles/apache/tests/test.yml new file mode 100644 index 0000000..9cd1316 --- /dev/null +++ b/mediawiki/roles/apache/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - apache-galaxy diff --git a/mediawiki/roles/apache/vars/main.yml b/mediawiki/roles/apache/vars/main.yml new file mode 100644 index 0000000..9be831f --- /dev/null +++ b/mediawiki/roles/apache/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for apache-galaxy diff --git a/mediawiki/roles/mariadb/tasks/main.yml b/mediawiki/roles/mariadb/tasks/main.yml new file mode 100644 index 0000000..72b6a41 --- /dev/null +++ b/mediawiki/roles/mariadb/tasks/main.yml @@ -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 diff --git a/mediawiki/roles/mediawiki/common/defaults/main.yml b/mediawiki/roles/mediawiki/common/defaults/main.yml new file mode 100644 index 0000000..b537573 --- /dev/null +++ b/mediawiki/roles/mediawiki/common/defaults/main.yml @@ -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" diff --git a/mediawiki/roles/mediawiki/configuration/meta/main.yml b/mediawiki/roles/mediawiki/configuration/meta/main.yml new file mode 100644 index 0000000..af852cc --- /dev/null +++ b/mediawiki/roles/mediawiki/configuration/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: + - role: "mediawiki/common" + + diff --git a/mediawiki/roles/mediawiki/configuration/tasks/main.yml b/mediawiki/roles/mediawiki/configuration/tasks/main.yml new file mode 100644 index 0000000..80d8b75 --- /dev/null +++ b/mediawiki/roles/mediawiki/configuration/tasks/main.yml @@ -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"; diff --git a/mediawiki/roles/mediawiki/mariadb/meta/main.yml b/mediawiki/roles/mediawiki/mariadb/meta/main.yml new file mode 100644 index 0000000..7640275 --- /dev/null +++ b/mediawiki/roles/mediawiki/mariadb/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - role: "mediawiki/common" + diff --git a/mediawiki/roles/mediawiki/mariadb/tasks/main.yml b/mediawiki/roles/mediawiki/mariadb/tasks/main.yml new file mode 100644 index 0000000..00a8ee0 --- /dev/null +++ b/mediawiki/roles/mediawiki/mariadb/tasks/main.yml @@ -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]) }}"