From aa1e170bbc39440d85b660aad530001e6f8de3e4 Mon Sep 17 00:00:00 2001 From: jerome Date: Fri, 18 Sep 2026 01:19:20 +0200 Subject: MAJ --- README.md | 38 +++++++++++++++++++++++++++ defaults/main.yml | 5 ++++ handlers/main.yml | 7 +++++ lamp/README.md | 38 --------------------------- lamp/defaults/main.yml | 5 ---- lamp/handlers/main.yml | 7 ----- lamp/meta/main.yml | 53 ------------------------------------- lamp/tasks/Debian-phpmyadmin.yml | 24 ----------------- lamp/tasks/RedHat-phpmyadmin.yml | 23 ---------------- lamp/tasks/clean_dbuser.yml | 13 --------- lamp/tasks/main.yml | 57 ---------------------------------------- lamp/tasks/test_dbuser.yml | 19 -------------- lamp/templates/index.j2 | 20 -------------- lamp/tests/inventory | 2 -- lamp/tests/test.yml | 5 ---- lamp/vars/Debian.yml | 14 ---------- lamp/vars/RedHat.yml | 14 ---------- lamp/vars/main.yml | 2 -- meta/main.yml | 53 +++++++++++++++++++++++++++++++++++++ tasks/Debian-phpmyadmin.yml | 24 +++++++++++++++++ tasks/RedHat-phpmyadmin.yml | 23 ++++++++++++++++ tasks/clean_dbuser.yml | 13 +++++++++ tasks/main.yml | 57 ++++++++++++++++++++++++++++++++++++++++ tasks/test_dbuser.yml | 19 ++++++++++++++ templates/index.j2 | 20 ++++++++++++++ tests/inventory | 2 ++ tests/test.yml | 5 ++++ vars/Debian.yml | 14 ++++++++++ vars/RedHat.yml | 14 ++++++++++ vars/main.yml | 2 ++ 30 files changed, 296 insertions(+), 296 deletions(-) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml delete mode 100644 lamp/README.md delete mode 100644 lamp/defaults/main.yml delete mode 100644 lamp/handlers/main.yml delete mode 100644 lamp/meta/main.yml delete mode 100644 lamp/tasks/Debian-phpmyadmin.yml delete mode 100644 lamp/tasks/RedHat-phpmyadmin.yml delete mode 100644 lamp/tasks/clean_dbuser.yml delete mode 100644 lamp/tasks/main.yml delete mode 100644 lamp/tasks/test_dbuser.yml delete mode 100644 lamp/templates/index.j2 delete mode 100644 lamp/tests/inventory delete mode 100644 lamp/tests/test.yml delete mode 100644 lamp/vars/Debian.yml delete mode 100644 lamp/vars/RedHat.yml delete mode 100644 lamp/vars/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/Debian-phpmyadmin.yml create mode 100644 tasks/RedHat-phpmyadmin.yml create mode 100644 tasks/clean_dbuser.yml create mode 100644 tasks/main.yml create mode 100644 tasks/test_dbuser.yml create mode 100644 templates/index.j2 create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml create mode 100644 vars/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/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/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..67be7ae --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +--- +# vars file for lamp + +db_user: toto +db_passwd: secret diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..b583d01 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,7 @@ +--- +# handlers file for lamp +- name: restarting_apache + service: + name: '{{apache.service}}' + state: restarted + diff --git a/lamp/README.md b/lamp/README.md deleted file mode 100644 index 225dd44..0000000 --- a/lamp/README.md +++ /dev/null @@ -1,38 +0,0 @@ -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/lamp/defaults/main.yml b/lamp/defaults/main.yml deleted file mode 100644 index 67be7ae..0000000 --- a/lamp/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -# vars file for lamp - -db_user: toto -db_passwd: secret diff --git a/lamp/handlers/main.yml b/lamp/handlers/main.yml deleted file mode 100644 index b583d01..0000000 --- a/lamp/handlers/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# handlers file for lamp -- name: restarting_apache - service: - name: '{{apache.service}}' - state: restarted - diff --git a/lamp/meta/main.yml b/lamp/meta/main.yml deleted file mode 100644 index 227ad9c..0000000 --- a/lamp/meta/main.yml +++ /dev/null @@ -1,53 +0,0 @@ -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.9 - - # 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. - \ No newline at end of file diff --git a/lamp/tasks/Debian-phpmyadmin.yml b/lamp/tasks/Debian-phpmyadmin.yml deleted file mode 100644 index 9da9a1b..0000000 --- a/lamp/tasks/Debian-phpmyadmin.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: configuration debconf - debconf: - name: phpmyadmin - question: 'phpmyadmin/reconfigure-webserver' - value: 'apache2' - vtype: select -- name: configuration debconf - debconf: - name: phpmyadmin - question: 'phpmyadmin/mysql/admin-pass' - value: '(password omitted)' - vtype: string -- name: configuration debconf - debconf: - name: phpmyadmin - question: 'phpmyadmin/dbconfig-install' - value : 'true' - vtype: boolean - -- name: installation phpmyadmin - package: - name: phpmyadmin - state: present diff --git a/lamp/tasks/RedHat-phpmyadmin.yml b/lamp/tasks/RedHat-phpmyadmin.yml deleted file mode 100644 index 569ddd2..0000000 --- a/lamp/tasks/RedHat-phpmyadmin.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: installation epel-release - package: - name: epel-release - state: present - -- name: installation phpmyadmin - package: - name: phpmyadmin - state: present - -- name: phpmyadmin.conf - replace: - path: /etc/httpd/conf.d/phpMyAdmin.conf - regexp: "Require local" - replace: "Require all granted" - after: "" - before: "" - notify: restarting_apache - -- name: database - shell: mysql < /usr/share/phpMyAdmin/sql/create_tables.sql - diff --git a/lamp/tasks/clean_dbuser.yml b/lamp/tasks/clean_dbuser.yml deleted file mode 100644 index 8d7d0cd..0000000 --- a/lamp/tasks/clean_dbuser.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: supprimer la base de données {{ db_user }} - community.mysql.mysql_db: - name: '{{ db_user }}' - state: absent - login_unix_socket: '{{mariadb.socket}}' - -- name: supprimer l'utilisateur {{ db_user }} - community.mysql.mysql_user: - name: '{{ db_user }}' - state: absent - login_unix_socket: '{{mariadb.socket}}' - diff --git a/lamp/tasks/main.yml b/lamp/tasks/main.yml deleted file mode 100644 index 0445a69..0000000 --- a/lamp/tasks/main.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -# tasks file for lamp -- include_vars: '{{ansible_os_family}}.yml' - tags: - - test - - clean - -- name: installation de lamp - package: - update_cache: true - name: "{{ lamp_packages }}" - state: present - -- name: activation des services sur Redhat - service: - state: started - name: '{{item}}' - with_items: - - httpd - - mariadb - when: ansible_os_family == 'RedHat' - -- name : activation du mod_rewrite d'apache sur Debian - community.general.apache2_module: - state: present - name: rewrite - when: ansible_os_family == 'Debian' - notify: - - restarting_apache - -- name: mise en place de index.html - template: - src: templates/index.j2 - dest: /var/www/html/index.html - owner: "{{apache.user}}" - group: "{{apache.user}}" - mode: 0644 - -- name: installation de phpmyadmin - include_tasks: - file: '{{ansible_os_family}}-phpmyadmin.yml' - apply: - tags: phpmyadmin - tags: phpmyadmin - -- name: test dbuser - import_tasks: test_dbuser.yml - tags: - - never - - test - -- name: clean dbuser - import_tasks: clean_dbuser.yml - tags: - - never - - clean - diff --git a/lamp/tasks/test_dbuser.yml b/lamp/tasks/test_dbuser.yml deleted file mode 100644 index c2243f3..0000000 --- a/lamp/tasks/test_dbuser.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: install dépendances python - package: - name: '{{ mariadb.pythonlib }}' - state: present - -- name: Créer la base de données {{ db_user }} - community.mysql.mysql_db: - name: '{{ db_user }}' - state: present - login_unix_socket: '{{mariadb.socket}}' - -- name: Créer un utilisateur {{ db_user }} - community.mysql.mysql_user: - name: '{{ db_user }}' - password: '{{ db_passwd }}' - priv: '{{ db_user }}.*:ALL' - state: present - login_unix_socket: '{{mariadb.socket}}' diff --git a/lamp/templates/index.j2 b/lamp/templates/index.j2 deleted file mode 100644 index 29619c2..0000000 --- a/lamp/templates/index.j2 +++ /dev/null @@ -1,20 +0,0 @@ - - - -{{ansible_distribution}} Apache Web Server - - - -

{{ansible_distribution}} Apache Web Server

-

Site en Constuction

-{% if lamp_packages is defined %} -

Packages :

- -{% endif %} -

Généré par {{ ansible_distribution }} {{ ansible_distribution_version }}

- - diff --git a/lamp/tests/inventory b/lamp/tests/inventory deleted file mode 100644 index 878877b..0000000 --- a/lamp/tests/inventory +++ /dev/null @@ -1,2 +0,0 @@ -localhost - diff --git a/lamp/tests/test.yml b/lamp/tests/test.yml deleted file mode 100644 index 10107f3..0000000 --- a/lamp/tests/test.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- hosts: localhost - remote_user: root - roles: - - lamp \ No newline at end of file diff --git a/lamp/vars/Debian.yml b/lamp/vars/Debian.yml deleted file mode 100644 index 1c7659f..0000000 --- a/lamp/vars/Debian.yml +++ /dev/null @@ -1,14 +0,0 @@ -lamp_packages: - - apache2 - - mariadb-server - - php - - php-mysql - -apache: - service: apache2 - user: www-data - -mariadb: - socket: /var/run/mysqld/mysqld.sock - pythonlib: python3-pymysql - diff --git a/lamp/vars/RedHat.yml b/lamp/vars/RedHat.yml deleted file mode 100644 index b8033ee..0000000 --- a/lamp/vars/RedHat.yml +++ /dev/null @@ -1,14 +0,0 @@ -lamp_packages: - - httpd - - mariadb-server - - php - - php-mysqlnd - -apache: - service: httpd - user: apache - -mariadb: - socket: /var/lib/mysql/mysql.sock - pythonlib: python3-PyMySQL - diff --git a/lamp/vars/main.yml b/lamp/vars/main.yml deleted file mode 100644 index 56675e7..0000000 --- a/lamp/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# vars file for lamp diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..227ad9c --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,53 @@ +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.9 + + # 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. + \ No newline at end of file diff --git a/tasks/Debian-phpmyadmin.yml b/tasks/Debian-phpmyadmin.yml new file mode 100644 index 0000000..9da9a1b --- /dev/null +++ b/tasks/Debian-phpmyadmin.yml @@ -0,0 +1,24 @@ +--- +- name: configuration debconf + debconf: + name: phpmyadmin + question: 'phpmyadmin/reconfigure-webserver' + value: 'apache2' + vtype: select +- name: configuration debconf + debconf: + name: phpmyadmin + question: 'phpmyadmin/mysql/admin-pass' + value: '(password omitted)' + vtype: string +- name: configuration debconf + debconf: + name: phpmyadmin + question: 'phpmyadmin/dbconfig-install' + value : 'true' + vtype: boolean + +- name: installation phpmyadmin + package: + name: phpmyadmin + state: present diff --git a/tasks/RedHat-phpmyadmin.yml b/tasks/RedHat-phpmyadmin.yml new file mode 100644 index 0000000..569ddd2 --- /dev/null +++ b/tasks/RedHat-phpmyadmin.yml @@ -0,0 +1,23 @@ +--- +- name: installation epel-release + package: + name: epel-release + state: present + +- name: installation phpmyadmin + package: + name: phpmyadmin + state: present + +- name: phpmyadmin.conf + replace: + path: /etc/httpd/conf.d/phpMyAdmin.conf + regexp: "Require local" + replace: "Require all granted" + after: "" + before: "" + notify: restarting_apache + +- name: database + shell: mysql < /usr/share/phpMyAdmin/sql/create_tables.sql + diff --git a/tasks/clean_dbuser.yml b/tasks/clean_dbuser.yml new file mode 100644 index 0000000..8d7d0cd --- /dev/null +++ b/tasks/clean_dbuser.yml @@ -0,0 +1,13 @@ +--- +- name: supprimer la base de données {{ db_user }} + community.mysql.mysql_db: + name: '{{ db_user }}' + state: absent + login_unix_socket: '{{mariadb.socket}}' + +- name: supprimer l'utilisateur {{ db_user }} + community.mysql.mysql_user: + name: '{{ db_user }}' + state: absent + login_unix_socket: '{{mariadb.socket}}' + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..0445a69 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,57 @@ +--- +# tasks file for lamp +- include_vars: '{{ansible_os_family}}.yml' + tags: + - test + - clean + +- name: installation de lamp + package: + update_cache: true + name: "{{ lamp_packages }}" + state: present + +- name: activation des services sur Redhat + service: + state: started + name: '{{item}}' + with_items: + - httpd + - mariadb + when: ansible_os_family == 'RedHat' + +- name : activation du mod_rewrite d'apache sur Debian + community.general.apache2_module: + state: present + name: rewrite + when: ansible_os_family == 'Debian' + notify: + - restarting_apache + +- name: mise en place de index.html + template: + src: templates/index.j2 + dest: /var/www/html/index.html + owner: "{{apache.user}}" + group: "{{apache.user}}" + mode: 0644 + +- name: installation de phpmyadmin + include_tasks: + file: '{{ansible_os_family}}-phpmyadmin.yml' + apply: + tags: phpmyadmin + tags: phpmyadmin + +- name: test dbuser + import_tasks: test_dbuser.yml + tags: + - never + - test + +- name: clean dbuser + import_tasks: clean_dbuser.yml + tags: + - never + - clean + diff --git a/tasks/test_dbuser.yml b/tasks/test_dbuser.yml new file mode 100644 index 0000000..c2243f3 --- /dev/null +++ b/tasks/test_dbuser.yml @@ -0,0 +1,19 @@ +--- +- name: install dépendances python + package: + name: '{{ mariadb.pythonlib }}' + state: present + +- name: Créer la base de données {{ db_user }} + community.mysql.mysql_db: + name: '{{ db_user }}' + state: present + login_unix_socket: '{{mariadb.socket}}' + +- name: Créer un utilisateur {{ db_user }} + community.mysql.mysql_user: + name: '{{ db_user }}' + password: '{{ db_passwd }}' + priv: '{{ db_user }}.*:ALL' + state: present + login_unix_socket: '{{mariadb.socket}}' diff --git a/templates/index.j2 b/templates/index.j2 new file mode 100644 index 0000000..29619c2 --- /dev/null +++ b/templates/index.j2 @@ -0,0 +1,20 @@ + + + +{{ansible_distribution}} Apache Web Server + + + +

{{ansible_distribution}} Apache Web Server

+

Site en Constuction

+{% if lamp_packages is defined %} +

Packages :

+ +{% endif %} +

Généré par {{ ansible_distribution }} {{ ansible_distribution_version }}

+ + diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..10107f3 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - lamp \ No newline at end of file diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..1c7659f --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,14 @@ +lamp_packages: + - apache2 + - mariadb-server + - php + - php-mysql + +apache: + service: apache2 + user: www-data + +mariadb: + socket: /var/run/mysqld/mysqld.sock + pythonlib: python3-pymysql + diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..b8033ee --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,14 @@ +lamp_packages: + - httpd + - mariadb-server + - php + - php-mysqlnd + +apache: + service: httpd + user: apache + +mariadb: + socket: /var/lib/mysql/mysql.sock + pythonlib: python3-PyMySQL + diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..56675e7 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for lamp -- cgit v1.2.3