From 04492c8bcc1e3f7e86dbb537a8c33c2f1ae40527 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Wed, 17 Mar 2021 22:39:43 +0100 Subject: [PATCH] rajout role a modifier --- tconstans.apache_formation/README.md | 38 +++++++++++++ tconstans.apache_formation/defaults/main.yml | 1 + tconstans.apache_formation/handlers/main.yml | 5 ++ .../meta/.galaxy_install_info | 2 + tconstans.apache_formation/meta/main.yml | 51 +++++++++++++++++ tconstans.apache_formation/tasks/apache.yml | 57 +++++++++++++++++++ tconstans.apache_formation/tasks/main.yml | 3 + .../templates/index.html | 1 + .../templates/vhost.conf | 23 ++++++++ tconstans.apache_formation/tests/inventory | 2 + tconstans.apache_formation/tests/test.yml | 4 ++ tconstans.apache_formation/vars/main.yml | 1 + 12 files changed, 188 insertions(+) create mode 100644 tconstans.apache_formation/README.md create mode 100644 tconstans.apache_formation/defaults/main.yml create mode 100644 tconstans.apache_formation/handlers/main.yml create mode 100644 tconstans.apache_formation/meta/.galaxy_install_info create mode 100644 tconstans.apache_formation/meta/main.yml create mode 100644 tconstans.apache_formation/tasks/apache.yml create mode 100644 tconstans.apache_formation/tasks/main.yml create mode 100644 tconstans.apache_formation/templates/index.html create mode 100644 tconstans.apache_formation/templates/vhost.conf create mode 100644 tconstans.apache_formation/tests/inventory create mode 100644 tconstans.apache_formation/tests/test.yml create mode 100644 tconstans.apache_formation/vars/main.yml diff --git a/tconstans.apache_formation/README.md b/tconstans.apache_formation/README.md new file mode 100644 index 0000000..6093f71 --- /dev/null +++ b/tconstans.apache_formation/README.md @@ -0,0 +1,38 @@ +Role Name +========= +apache_formation + +NOT FOR PRODUCTION USE + +This role has been designed for training purpose + +Requirements +------------ + +None + +Role Variables +-------------- + +Dependencies +------------ + +None + +Example Playbook +---------------- + +--- +- hosts: test + roles: + - apache_formation + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/tconstans.apache_formation/defaults/main.yml b/tconstans.apache_formation/defaults/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tconstans.apache_formation/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/tconstans.apache_formation/handlers/main.yml b/tconstans.apache_formation/handlers/main.yml new file mode 100644 index 0000000..bd503d2 --- /dev/null +++ b/tconstans.apache_formation/handlers/main.yml @@ -0,0 +1,5 @@ +--- + - name: reload httpd + service: + name: httpd + state: reloaded diff --git a/tconstans.apache_formation/meta/.galaxy_install_info b/tconstans.apache_formation/meta/.galaxy_install_info new file mode 100644 index 0000000..01f5bd7 --- /dev/null +++ b/tconstans.apache_formation/meta/.galaxy_install_info @@ -0,0 +1,2 @@ +install_date: Sat Sep 19 19:38:41 2020 +version: master diff --git a/tconstans.apache_formation/meta/main.yml b/tconstans.apache_formation/meta/main.yml new file mode 100644 index 0000000..38015ad --- /dev/null +++ b/tconstans.apache_formation/meta/main.yml @@ -0,0 +1,51 @@ +galaxy_info: + role_name: apache_formation + author: Thomas Constans + description: Simple apache role set up for training purpose + company: www.opendoor.fr + + # 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: GPLv2 + + min_ansible_version: 1.2 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # platforms is a list of platforms, and each platform has a name and a list of versions. + # + platforms: + - name: EL + versions: + - 7 + + galaxy_tags: [apache,training] + # 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/tconstans.apache_formation/tasks/apache.yml b/tconstans.apache_formation/tasks/apache.yml new file mode 100644 index 0000000..7d5d072 --- /dev/null +++ b/tconstans.apache_formation/tasks/apache.yml @@ -0,0 +1,57 @@ +--- +- name: installation + package: + name: httpd + state: present + +- name: configuration + notify: reload httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + +- name: enable service + service: + name: httpd + enabled: yes + +- name: open firewall port + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + +- name: create documentroot + file: + name: "/var/www/opendoor.fr" + state: directory + +- name: create index file + template: + src: index.html + dest: "/var/www/opendoor.fr/index.html" + mode: 0644 + +- name: install python passlib package + package: + name: python-passlib + state: present + +- name: passwd file + htpasswd: + path: "/etc/httpd/passwd" + name: tom + password: "123Soleil" + mode: 0640 + owner: root + group: "apache" + +- name: start service + service: + name: httpd + state: started \ No newline at end of file diff --git a/tconstans.apache_formation/tasks/main.yml b/tconstans.apache_formation/tasks/main.yml new file mode 100644 index 0000000..239d2eb --- /dev/null +++ b/tconstans.apache_formation/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: apache.yml + tags: httpd \ No newline at end of file diff --git a/tconstans.apache_formation/templates/index.html b/tconstans.apache_formation/templates/index.html new file mode 100644 index 0000000..675be45 --- /dev/null +++ b/tconstans.apache_formation/templates/index.html @@ -0,0 +1 @@ +

Welcome aboard {{ ansible_hostname }}

\ No newline at end of file diff --git a/tconstans.apache_formation/templates/vhost.conf b/tconstans.apache_formation/templates/vhost.conf new file mode 100644 index 0000000..223b387 --- /dev/null +++ b/tconstans.apache_formation/templates/vhost.conf @@ -0,0 +1,23 @@ + + ServerName orsys.fr + ServerAlias www.orsys.fr + DocumentRoot /var/www/html/orsys.fr + CustomLog /var/log/httpd/orsys.fr_access.log combined + ErrorLog /var/log/httpd/orsys.fr_error.log + + Options none + Allowoverride none + Require all denied + + + + Require all granted + + + Options indexes + AuthName "stop" + AuthType Basic + AuthUserFile /etc/httpd/passwd + require valid-user + + \ No newline at end of file diff --git a/tconstans.apache_formation/tests/inventory b/tconstans.apache_formation/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tconstans.apache_formation/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tconstans.apache_formation/tests/test.yml b/tconstans.apache_formation/tests/test.yml new file mode 100644 index 0000000..3af12d2 --- /dev/null +++ b/tconstans.apache_formation/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: centos + roles: + - tconstans.ansible_apache_formation \ No newline at end of file diff --git a/tconstans.apache_formation/vars/main.yml b/tconstans.apache_formation/vars/main.yml new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/tconstans.apache_formation/vars/main.yml @@ -0,0 +1 @@ +--- \ No newline at end of file