From 4acecc8e04ca92e35bfc4fbcd73bad01c49c8bfc Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Mon, 8 Jan 2018 19:24:19 +0100 Subject: [PATCH] Exercice: commit initial --- 0README | 9 + 10_premier_playbook/apache.yml | 43 ++ 10_premier_playbook/index.html | 1 + 10_premier_playbook/vhost.conf | 17 + 11_gestion_erreurs/apache.yml | 38 ++ 12_handlers/apache.yml | 54 ++ 12_handlers/index.html | 1 + 12_handlers/vhost.conf | 17 + 14_tags/apache.yml | 61 +++ 15_roles/apache.yml | 6 + 15_roles/myapache/README.md | 38 ++ 15_roles/myapache/defaults/main.yml | 2 + 15_roles/myapache/files/index.html | 1 + 15_roles/myapache/files/vhost.conf | 17 + 15_roles/myapache/handlers/main.yml | 11 + 15_roles/myapache/meta/main.yml | 57 +++ 15_roles/myapache/tasks/main.yml | 47 ++ 15_roles/myapache/tests/inventory | 2 + 15_roles/myapache/tests/test.yml | 5 + 15_roles/myapache/vars/main.yml | 2 + 16_galaxy/apache_geerlingguy.yml | 12 + 17.1_variable/apache.yml | 8 + 17.1_variable/myapache/README.md | 45 ++ 17.1_variable/myapache/defaults/main.yml | 2 + 17.1_variable/myapache/files/index.html | 1 + 17.1_variable/myapache/handlers/main.yml | 11 + 17.1_variable/myapache/meta/main.yml | 57 +++ 17.1_variable/myapache/tasks/main.yml | 46 ++ .../myapache/templates/vhost.conf.jj | 16 + 17.1_variable/myapache/tests/inventory | 2 + 17.1_variable/myapache/tests/test.yml | 5 + 17.1_variable/myapache/vars/main.yml | 8 + 17.2_variable/apache.yml | 7 + 17.2_variable/myapache2/README.md | 45 ++ 17.2_variable/myapache2/defaults/main.yml | 2 + 17.2_variable/myapache2/files/index.html | 1 + 17.2_variable/myapache2/handlers/main.yml | 11 + 17.2_variable/myapache2/meta/main.yml | 57 +++ 17.2_variable/myapache2/tasks/main.yml | 50 ++ .../myapache2/templates/vhost.conf.jj | 18 + 17.2_variable/myapache2/tests/inventory | 2 + 17.2_variable/myapache2/tests/test.yml | 5 + 17.2_variable/myapache2/vars/main.yml | 14 + 17.3_variable/apache.yml | 7 + 17.3_variable/myapache3/README.md | 45 ++ 17.3_variable/myapache3/defaults/main.yml | 2 + 17.3_variable/myapache3/files/index.html | 1 + 17.3_variable/myapache3/handlers/main.yml | 11 + 17.3_variable/myapache3/meta/main.yml | 57 +++ 17.3_variable/myapache3/tasks/main.yml | 50 ++ .../myapache3/templates/.vhost.conf.jj.swp | Bin 0 -> 12288 bytes .../myapache3/templates/vhost.conf.jj | 19 + 17.3_variable/myapache3/tests/inventory | 2 + 17.3_variable/myapache3/tests/test.yml | 5 + 17.3_variable/myapache3/vars/.main.yml.swp | Bin 0 -> 12288 bytes 17.3_variable/myapache3/vars/main.yml | 15 + 20_conditions/apache.yml | 7 + 20_conditions/myapache4/README.md | 45 ++ 20_conditions/myapache4/defaults/main.yml | 2 + 20_conditions/myapache4/files/index.html | 1 + 20_conditions/myapache4/handlers/main.yml | 11 + 20_conditions/myapache4/meta/main.yml | 57 +++ 20_conditions/myapache4/tasks/main.yml | 55 ++ .../myapache4/templates/vhost.conf.jj | 19 + 20_conditions/myapache4/tests/inventory | 2 + 20_conditions/myapache4/tests/test.yml | 5 + 20_conditions/myapache4/vars/centos.yml | 1 + 20_conditions/myapache4/vars/debian.yml | 7 + 20_conditions/myapache4/vars/main.yml | 15 + 20_conditions/myapache4/vars/redhat.yml | 7 + 21_myphp/myphp/README.md | 38 ++ 21_myphp/myphp/defaults/main.yml | 2 + 21_myphp/myphp/handlers/main.yml | 2 + 21_myphp/myphp/meta/main.yml | 57 +++ 21_myphp/myphp/tasks/main.yml | 13 + 21_myphp/myphp/tests/inventory | 2 + 21_myphp/myphp/tests/test.yml | 5 + 21_myphp/myphp/vars/centos.yml | 6 + 21_myphp/myphp/vars/debian.yml | 6 + 21_myphp/myphp/vars/main.yml | 2 + 21_myphp/myphp/vars/redhat.yml | 6 + 21_myphp/php.yml | 9 + 23_prompts/apache.yml | 11 + 23_prompts/myapache5/README.md | 45 ++ 23_prompts/myapache5/defaults/main.yml | 2 + 23_prompts/myapache5/files/index.html | 1 + 23_prompts/myapache5/handlers/main.yml | 11 + 23_prompts/myapache5/meta/main.yml | 57 +++ 23_prompts/myapache5/tasks/main.yml | 71 +++ 23_prompts/myapache5/templates/vhost.conf.jj | 28 ++ 23_prompts/myapache5/tests/inventory | 2 + 23_prompts/myapache5/tests/test.yml | 5 + 23_prompts/myapache5/vars/centos.yml | 1 + 23_prompts/myapache5/vars/debian.yml | 7 + 23_prompts/myapache5/vars/main.yml | 15 + 23_prompts/myapache5/vars/redhat.yml | 7 + 25_vaults/apache.yml | 7 + 25_vaults/myapache/README.md | 45 ++ 25_vaults/myapache/defaults/main.yml | 2 + 25_vaults/myapache/files/index.html | 1 + 25_vaults/myapache/handlers/main.yml | 11 + 25_vaults/myapache/meta/main.yml | 57 +++ 25_vaults/myapache/tasks/main.yml | 75 +++ 25_vaults/myapache/templates/vhost.conf.jj | 28 ++ 25_vaults/myapache/tests/inventory | 2 + 25_vaults/myapache/tests/test.yml | 5 + .../myapache/vars/apache_sensitive_data.yml | 6 + 25_vaults/myapache/vars/centos.yml | 1 + 25_vaults/myapache/vars/debian.yml | 7 + 25_vaults/myapache/vars/main.yml | 15 + 25_vaults/myapache/vars/redhat.yml | 7 + ansible.png | Bin 0 -> 5164 bytes ansible_stock.cfg | 470 ++++++++++++++++++ debug.yml | 13 + 114 files changed, 2465 insertions(+) create mode 100644 0README create mode 100644 10_premier_playbook/apache.yml create mode 100644 10_premier_playbook/index.html create mode 100644 10_premier_playbook/vhost.conf create mode 100644 11_gestion_erreurs/apache.yml create mode 100644 12_handlers/apache.yml create mode 100644 12_handlers/index.html create mode 100644 12_handlers/vhost.conf create mode 100644 14_tags/apache.yml create mode 100644 15_roles/apache.yml create mode 100644 15_roles/myapache/README.md create mode 100644 15_roles/myapache/defaults/main.yml create mode 100644 15_roles/myapache/files/index.html create mode 100644 15_roles/myapache/files/vhost.conf create mode 100644 15_roles/myapache/handlers/main.yml create mode 100644 15_roles/myapache/meta/main.yml create mode 100644 15_roles/myapache/tasks/main.yml create mode 100644 15_roles/myapache/tests/inventory create mode 100644 15_roles/myapache/tests/test.yml create mode 100644 15_roles/myapache/vars/main.yml create mode 100644 16_galaxy/apache_geerlingguy.yml create mode 100644 17.1_variable/apache.yml create mode 100644 17.1_variable/myapache/README.md create mode 100644 17.1_variable/myapache/defaults/main.yml create mode 100644 17.1_variable/myapache/files/index.html create mode 100644 17.1_variable/myapache/handlers/main.yml create mode 100644 17.1_variable/myapache/meta/main.yml create mode 100644 17.1_variable/myapache/tasks/main.yml create mode 100644 17.1_variable/myapache/templates/vhost.conf.jj create mode 100644 17.1_variable/myapache/tests/inventory create mode 100644 17.1_variable/myapache/tests/test.yml create mode 100644 17.1_variable/myapache/vars/main.yml create mode 100644 17.2_variable/apache.yml create mode 100644 17.2_variable/myapache2/README.md create mode 100644 17.2_variable/myapache2/defaults/main.yml create mode 100644 17.2_variable/myapache2/files/index.html create mode 100644 17.2_variable/myapache2/handlers/main.yml create mode 100644 17.2_variable/myapache2/meta/main.yml create mode 100644 17.2_variable/myapache2/tasks/main.yml create mode 100644 17.2_variable/myapache2/templates/vhost.conf.jj create mode 100644 17.2_variable/myapache2/tests/inventory create mode 100644 17.2_variable/myapache2/tests/test.yml create mode 100644 17.2_variable/myapache2/vars/main.yml create mode 100644 17.3_variable/apache.yml create mode 100644 17.3_variable/myapache3/README.md create mode 100644 17.3_variable/myapache3/defaults/main.yml create mode 100644 17.3_variable/myapache3/files/index.html create mode 100644 17.3_variable/myapache3/handlers/main.yml create mode 100644 17.3_variable/myapache3/meta/main.yml create mode 100644 17.3_variable/myapache3/tasks/main.yml create mode 100644 17.3_variable/myapache3/templates/.vhost.conf.jj.swp create mode 100644 17.3_variable/myapache3/templates/vhost.conf.jj create mode 100644 17.3_variable/myapache3/tests/inventory create mode 100644 17.3_variable/myapache3/tests/test.yml create mode 100644 17.3_variable/myapache3/vars/.main.yml.swp create mode 100644 17.3_variable/myapache3/vars/main.yml create mode 100644 20_conditions/apache.yml create mode 100644 20_conditions/myapache4/README.md create mode 100644 20_conditions/myapache4/defaults/main.yml create mode 100644 20_conditions/myapache4/files/index.html create mode 100644 20_conditions/myapache4/handlers/main.yml create mode 100644 20_conditions/myapache4/meta/main.yml create mode 100644 20_conditions/myapache4/tasks/main.yml create mode 100644 20_conditions/myapache4/templates/vhost.conf.jj create mode 100644 20_conditions/myapache4/tests/inventory create mode 100644 20_conditions/myapache4/tests/test.yml create mode 120000 20_conditions/myapache4/vars/centos.yml create mode 100644 20_conditions/myapache4/vars/debian.yml create mode 100644 20_conditions/myapache4/vars/main.yml create mode 100644 20_conditions/myapache4/vars/redhat.yml create mode 100644 21_myphp/myphp/README.md create mode 100644 21_myphp/myphp/defaults/main.yml create mode 100644 21_myphp/myphp/handlers/main.yml create mode 100644 21_myphp/myphp/meta/main.yml create mode 100644 21_myphp/myphp/tasks/main.yml create mode 100644 21_myphp/myphp/tests/inventory create mode 100644 21_myphp/myphp/tests/test.yml create mode 100644 21_myphp/myphp/vars/centos.yml create mode 100644 21_myphp/myphp/vars/debian.yml create mode 100644 21_myphp/myphp/vars/main.yml create mode 100644 21_myphp/myphp/vars/redhat.yml create mode 100644 21_myphp/php.yml create mode 100644 23_prompts/apache.yml create mode 100644 23_prompts/myapache5/README.md create mode 100644 23_prompts/myapache5/defaults/main.yml create mode 100644 23_prompts/myapache5/files/index.html create mode 100644 23_prompts/myapache5/handlers/main.yml create mode 100644 23_prompts/myapache5/meta/main.yml create mode 100644 23_prompts/myapache5/tasks/main.yml create mode 100644 23_prompts/myapache5/templates/vhost.conf.jj create mode 100644 23_prompts/myapache5/tests/inventory create mode 100644 23_prompts/myapache5/tests/test.yml create mode 120000 23_prompts/myapache5/vars/centos.yml create mode 100644 23_prompts/myapache5/vars/debian.yml create mode 100644 23_prompts/myapache5/vars/main.yml create mode 100644 23_prompts/myapache5/vars/redhat.yml create mode 100644 25_vaults/apache.yml create mode 100644 25_vaults/myapache/README.md create mode 100644 25_vaults/myapache/defaults/main.yml create mode 100644 25_vaults/myapache/files/index.html create mode 100644 25_vaults/myapache/handlers/main.yml create mode 100644 25_vaults/myapache/meta/main.yml create mode 100644 25_vaults/myapache/tasks/main.yml create mode 100644 25_vaults/myapache/templates/vhost.conf.jj create mode 100644 25_vaults/myapache/tests/inventory create mode 100644 25_vaults/myapache/tests/test.yml create mode 100644 25_vaults/myapache/vars/apache_sensitive_data.yml create mode 120000 25_vaults/myapache/vars/centos.yml create mode 100644 25_vaults/myapache/vars/debian.yml create mode 100644 25_vaults/myapache/vars/main.yml create mode 100644 25_vaults/myapache/vars/redhat.yml create mode 100644 ansible.png create mode 100644 ansible_stock.cfg create mode 100644 debug.yml diff --git a/0README b/0README new file mode 100644 index 0000000..6629c1f --- /dev/null +++ b/0README @@ -0,0 +1,9 @@ +Prérequis: lancer ssh +ouvrire parefeu +Chaque sous répertoire peut être récupéré via git: + +Compte: formation +Mot de passe: F1234 + +echo "Host {{ ip_formateur }}\nPort 2222\nUser formation" >> ~/.ssh/config +git clone ip_formateur:/home/tom/Current/Corrections/N diff --git a/10_premier_playbook/apache.yml b/10_premier_playbook/apache.yml new file mode 100644 index 0000000..72d26d6 --- /dev/null +++ b/10_premier_playbook/apache.yml @@ -0,0 +1,43 @@ +--- +- name: install apache via ansible playbook + hosts: test + become: false + user: root + tasks: + - name: install apache + yum: + name: httpd + state: latest + + - name: conf httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + + - name: activate apache + service: + name: httpd + enabled: yes + state: restarted + + - name: open firewall port + tags: dev + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + + - name: create documentroot + file: + name: /var/www/html/orsys.fr + state: directory + + - name: copy index file + copy: + src: index.html + dest: /var/www/html/orsys.fr/index.html + mode: 0644 \ No newline at end of file diff --git a/10_premier_playbook/index.html b/10_premier_playbook/index.html new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/10_premier_playbook/index.html @@ -0,0 +1 @@ +test diff --git a/10_premier_playbook/vhost.conf b/10_premier_playbook/vhost.conf new file mode 100644 index 0000000..b352f6d --- /dev/null +++ b/10_premier_playbook/vhost.conf @@ -0,0 +1,17 @@ + + ServerName orsys.fr + ServerAlias www.orsys.fr + ServerAlias 100.0.0.100 + 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 + + \ No newline at end of file diff --git a/11_gestion_erreurs/apache.yml b/11_gestion_erreurs/apache.yml new file mode 100644 index 0000000..072ddf2 --- /dev/null +++ b/11_gestion_erreurs/apache.yml @@ -0,0 +1,38 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + tasks: + - name: install apache + yum: + name: httpd + state: latest + - name: conf httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + - name: activate apache + service: + name: httpd + enabled: yes + state: restarted + - name: open firewall port + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + - name: create documentroot + file: + name: /var/www/html/orsys.fr + state: directory + - name: create index file + copy: + src: index.html + dest: /var/www/html/orsys.fr/index.html + mode: 0644 \ No newline at end of file diff --git a/12_handlers/apache.yml b/12_handlers/apache.yml new file mode 100644 index 0000000..55d03a9 --- /dev/null +++ b/12_handlers/apache.yml @@ -0,0 +1,54 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + handlers: + - name: reload httpd + service: + name: httpd + state: restarted + + - name: reload firewalld + service: + name: firewalld + state: reloaded + + tasks: + - name: install apache + yum: + name: httpd + state: latest + - name: conf httpd + notify: reload httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + + - name: activate apache + service: + name: httpd + enabled: yes + + - name: open firewall port + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + + - name: create documentroot + file: + name: /var/www/html/orsys.fr + state: directory + + - name: create index file + copy: + src: index.html + dest: /var/www/html/orsys.fr/index.html + mode: 0644 \ No newline at end of file diff --git a/12_handlers/index.html b/12_handlers/index.html new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/12_handlers/index.html @@ -0,0 +1 @@ +test diff --git a/12_handlers/vhost.conf b/12_handlers/vhost.conf new file mode 100644 index 0000000..b352f6d --- /dev/null +++ b/12_handlers/vhost.conf @@ -0,0 +1,17 @@ + + ServerName orsys.fr + ServerAlias www.orsys.fr + ServerAlias 100.0.0.100 + 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 + + \ No newline at end of file diff --git a/14_tags/apache.yml b/14_tags/apache.yml new file mode 100644 index 0000000..82acb33 --- /dev/null +++ b/14_tags/apache.yml @@ -0,0 +1,61 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + handlers: + - name: reload httpd + service: + name: httpd + state: reloaded + + - name: reload firewalld + service: + name: firewalld + state: reloaded + + tasks: + - name: install apache + tags: httpd + yum: + name: httpd + state: latest + - name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + + - name: activate apache + tags: httpd + service: + name: httpd + enabled: yes + state: restarted + + - name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + + - name: create documentroot + tags: httpd + file: + name: /var/www/html/orsys.fr + state: directory + + - name: create index file + tags: httpd + copy: + src: index.html + dest: /var/www/html/orsys.fr/index.html + mode: 0644 \ No newline at end of file diff --git a/15_roles/apache.yml b/15_roles/apache.yml new file mode 100644 index 0000000..8053656 --- /dev/null +++ b/15_roles/apache.yml @@ -0,0 +1,6 @@ +--- +- hosts: test + become: true + user: formation + roles: + - myapache \ No newline at end of file diff --git a/15_roles/myapache/README.md b/15_roles/myapache/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/15_roles/myapache/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/15_roles/myapache/defaults/main.yml b/15_roles/myapache/defaults/main.yml new file mode 100644 index 0000000..0555fef --- /dev/null +++ b/15_roles/myapache/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for 15_apache \ No newline at end of file diff --git a/15_roles/myapache/files/index.html b/15_roles/myapache/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/15_roles/myapache/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/15_roles/myapache/files/vhost.conf b/15_roles/myapache/files/vhost.conf new file mode 100644 index 0000000..b352f6d --- /dev/null +++ b/15_roles/myapache/files/vhost.conf @@ -0,0 +1,17 @@ + + ServerName orsys.fr + ServerAlias www.orsys.fr + ServerAlias 100.0.0.100 + 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 + + \ No newline at end of file diff --git a/15_roles/myapache/handlers/main.yml b/15_roles/myapache/handlers/main.yml new file mode 100644 index 0000000..6431140 --- /dev/null +++ b/15_roles/myapache/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for 15_apache + - name: reload httpd + service: + name: httpd + state: reloaded + + - name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/15_roles/myapache/meta/main.yml b/15_roles/myapache/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/15_roles/myapache/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/15_roles/myapache/tasks/main.yml b/15_roles/myapache/tasks/main.yml new file mode 100644 index 0000000..e82f203 --- /dev/null +++ b/15_roles/myapache/tasks/main.yml @@ -0,0 +1,47 @@ +--- +# tasks file for 15_apache +- name: install apache + tags: httpd + yum: + name: httpd + state: latest + +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + +- name: activate apache + tags: httpd + service: + name: httpd + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + +- name: create documentroot + tags: httpd + file: + name: /var/www/html/orsys.fr + state: directory + +- name: create index file + tags: httpd + copy: + src: index.html + dest: /var/www/html/orsys.fr/index.html + mode: 0644 \ No newline at end of file diff --git a/15_roles/myapache/tests/inventory b/15_roles/myapache/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/15_roles/myapache/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/15_roles/myapache/tests/test.yml b/15_roles/myapache/tests/test.yml new file mode 100644 index 0000000..63de714 --- /dev/null +++ b/15_roles/myapache/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - 15_apache \ No newline at end of file diff --git a/15_roles/myapache/vars/main.yml b/15_roles/myapache/vars/main.yml new file mode 100644 index 0000000..89fc479 --- /dev/null +++ b/15_roles/myapache/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for 15_apache \ No newline at end of file diff --git a/16_galaxy/apache_geerlingguy.yml b/16_galaxy/apache_geerlingguy.yml new file mode 100644 index 0000000..4d5a277 --- /dev/null +++ b/16_galaxy/apache_geerlingguy.yml @@ -0,0 +1,12 @@ +--- +- hosts: test + become: true + user: formation + vars: + - apache_vhosts: + - servername: vhost1 + documentroot: /var/www/html/vhost1 + - servername: vhost2 + documentroot: /var/www/html/vhost2 + roles: + - geerlingguy.apach \ No newline at end of file diff --git a/17.1_variable/apache.yml b/17.1_variable/apache.yml new file mode 100644 index 0000000..5f9d022 --- /dev/null +++ b/17.1_variable/apache.yml @@ -0,0 +1,8 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + roles: + - { role: myapache, servername: 'thomas.fr' } + - { role: myapache, servername: 'sophie.fr' } diff --git a/17.1_variable/myapache/README.md b/17.1_variable/myapache/README.md new file mode 100644 index 0000000..4b2f3e0 --- /dev/null +++ b/17.1_variable/myapache/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Rôle de deploiement apache sur une centos. + +1 seul vhost + +Requirements +------------ + +None + +Role Variables +-------------- + +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log + +Dependencies +------------ + +None + +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: + - { myapache } + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/17.1_variable/myapache/defaults/main.yml b/17.1_variable/myapache/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/17.1_variable/myapache/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/17.1_variable/myapache/files/index.html b/17.1_variable/myapache/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/17.1_variable/myapache/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/17.1_variable/myapache/handlers/main.yml b/17.1_variable/myapache/handlers/main.yml new file mode 100644 index 0000000..c72410b --- /dev/null +++ b/17.1_variable/myapache/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: httpd + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/17.1_variable/myapache/meta/main.yml b/17.1_variable/myapache/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/17.1_variable/myapache/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/17.1_variable/myapache/tasks/main.yml b/17.1_variable/myapache/tasks/main.yml new file mode 100644 index 0000000..6aebeb1 --- /dev/null +++ b/17.1_variable/myapache/tasks/main.yml @@ -0,0 +1,46 @@ +--- +# tasks file for myapache +- name: install apache + tags: httpd + yum: + name: httpd + state: latest +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: /etc/httpd/conf.d/vhost_{{servername}}.conf + mode: 0640 + owner: root + group: apache + +- name: activate apache + tags: httpd + service: + name: httpd + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + +- name: create documentroot + tags: httpd + file: + name: "/var/www/html/{{ servername }}" + state: directory + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "/var/www/html/{{ servername }}/index.html" + mode: 0644 \ No newline at end of file diff --git a/17.1_variable/myapache/templates/vhost.conf.jj b/17.1_variable/myapache/templates/vhost.conf.jj new file mode 100644 index 0000000..12574a1 --- /dev/null +++ b/17.1_variable/myapache/templates/vhost.conf.jj @@ -0,0 +1,16 @@ + + ServerName {{ servername }} + ServerAlias {{ serveralias }} + DocumentRoot {{ documentroot }} + CustomLog {{ accesslog }} combined + ErrorLog {{ errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Require all granted + + \ No newline at end of file diff --git a/17.1_variable/myapache/tests/inventory b/17.1_variable/myapache/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/17.1_variable/myapache/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/17.1_variable/myapache/tests/test.yml b/17.1_variable/myapache/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/17.1_variable/myapache/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/17.1_variable/myapache/vars/main.yml b/17.1_variable/myapache/vars/main.yml new file mode 100644 index 0000000..2cec6bd --- /dev/null +++ b/17.1_variable/myapache/vars/main.yml @@ -0,0 +1,8 @@ +--- +# vars file for myapache +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log \ No newline at end of file diff --git a/17.2_variable/apache.yml b/17.2_variable/apache.yml new file mode 100644 index 0000000..af83f74 --- /dev/null +++ b/17.2_variable/apache.yml @@ -0,0 +1,7 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + roles: + - myapache2 diff --git a/17.2_variable/myapache2/README.md b/17.2_variable/myapache2/README.md new file mode 100644 index 0000000..4b2f3e0 --- /dev/null +++ b/17.2_variable/myapache2/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Rôle de deploiement apache sur une centos. + +1 seul vhost + +Requirements +------------ + +None + +Role Variables +-------------- + +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log + +Dependencies +------------ + +None + +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: + - { myapache } + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/17.2_variable/myapache2/defaults/main.yml b/17.2_variable/myapache2/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/17.2_variable/myapache2/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/17.2_variable/myapache2/files/index.html b/17.2_variable/myapache2/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/17.2_variable/myapache2/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/17.2_variable/myapache2/handlers/main.yml b/17.2_variable/myapache2/handlers/main.yml new file mode 100644 index 0000000..c72410b --- /dev/null +++ b/17.2_variable/myapache2/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: httpd + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/17.2_variable/myapache2/meta/main.yml b/17.2_variable/myapache2/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/17.2_variable/myapache2/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/17.2_variable/myapache2/tasks/main.yml b/17.2_variable/myapache2/tasks/main.yml new file mode 100644 index 0000000..80264b3 --- /dev/null +++ b/17.2_variable/myapache2/tasks/main.yml @@ -0,0 +1,50 @@ +--- +# tasks file for myapache +- name: install apache + tags: httpd + yum: + name: httpd + state: latest +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: /etc/httpd/conf.d/vhost_.conf + mode: 0640 + owner: root + group: apache + +- name: activate apache + tags: httpd + service: + name: httpd + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + +- name: create documentroot + tags: httpd + file: + name: "/var/www/html/{{ item.documentroot }}" + state: directory + with_items: + - "{{ apache_vhosts }}" + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "/var/www/html/{{ item.documentroot }}/index.html" + mode: 0644 + with_items: + - "{{ apache_vhosts }}" \ No newline at end of file diff --git a/17.2_variable/myapache2/templates/vhost.conf.jj b/17.2_variable/myapache2/templates/vhost.conf.jj new file mode 100644 index 0000000..44b2a99 --- /dev/null +++ b/17.2_variable/myapache2/templates/vhost.conf.jj @@ -0,0 +1,18 @@ +{% for vhost in apache_vhosts %} + + ServerName {{ vhost.servername }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Require all granted + + +{% endfor %} \ No newline at end of file diff --git a/17.2_variable/myapache2/tests/inventory b/17.2_variable/myapache2/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/17.2_variable/myapache2/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/17.2_variable/myapache2/tests/test.yml b/17.2_variable/myapache2/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/17.2_variable/myapache2/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/17.2_variable/myapache2/vars/main.yml b/17.2_variable/myapache2/vars/main.yml new file mode 100644 index 0000000..264638c --- /dev/null +++ b/17.2_variable/myapache2/vars/main.yml @@ -0,0 +1,14 @@ +--- +# vars file for myapache +http_port: 80 +apache_vhosts: +- servername: orsys.fr + serveralias: www.orsys.fr + documentroot: /var/www/html/orsys.fr + accesslog: /var/log/httpd/access_orsys.fr_log + errorlog: /var/log/httpd/error_orsys.fr_log +- servername: thomas.fr + serveralias: www.thomas.fr + documentroot: /var/www/html/thomas.fr + accesslog: /var/log/httpd/access_thomas.fr_log + errorlog: /var/log/httpd/error_thomas.fr_log \ No newline at end of file diff --git a/17.3_variable/apache.yml b/17.3_variable/apache.yml new file mode 100644 index 0000000..19313a5 --- /dev/null +++ b/17.3_variable/apache.yml @@ -0,0 +1,7 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + roles: + - myapache3 diff --git a/17.3_variable/myapache3/README.md b/17.3_variable/myapache3/README.md new file mode 100644 index 0000000..4b2f3e0 --- /dev/null +++ b/17.3_variable/myapache3/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Rôle de deploiement apache sur une centos. + +1 seul vhost + +Requirements +------------ + +None + +Role Variables +-------------- + +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log + +Dependencies +------------ + +None + +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: + - { myapache } + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/17.3_variable/myapache3/defaults/main.yml b/17.3_variable/myapache3/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/17.3_variable/myapache3/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/17.3_variable/myapache3/files/index.html b/17.3_variable/myapache3/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/17.3_variable/myapache3/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/17.3_variable/myapache3/handlers/main.yml b/17.3_variable/myapache3/handlers/main.yml new file mode 100644 index 0000000..c72410b --- /dev/null +++ b/17.3_variable/myapache3/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: httpd + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/17.3_variable/myapache3/meta/main.yml b/17.3_variable/myapache3/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/17.3_variable/myapache3/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/17.3_variable/myapache3/tasks/main.yml b/17.3_variable/myapache3/tasks/main.yml new file mode 100644 index 0000000..9c648cf --- /dev/null +++ b/17.3_variable/myapache3/tasks/main.yml @@ -0,0 +1,50 @@ +--- +# tasks file for myapache +- name: install apache + tags: httpd + yum: + name: httpd + state: latest +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: /etc/httpd/conf.d/vhost.conf + mode: 0640 + owner: root + group: apache + +- name: activate apache + tags: httpd + service: + name: httpd + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + +- name: create documentroot + tags: httpd + file: + name: "/var/www/html/{{ item.documentroot }}" + state: directory + with_items: + - "{{ apache_vhosts }}" + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "/var/www/html/{{ item.documentroot }}/index.html" + mode: 0644 + with_items: + - "{{ apache_vhosts }}" \ No newline at end of file diff --git a/17.3_variable/myapache3/templates/.vhost.conf.jj.swp b/17.3_variable/myapache3/templates/.vhost.conf.jj.swp new file mode 100644 index 0000000000000000000000000000000000000000..822844ee71012b3667827cebeef9f5b19a5b300e GIT binary patch literal 12288 zcmeI2&ubGw6vtl*9&)IPy?PiU5%rL*R!}4aN-J3L2ejCOmoVL(BwKcO*4as<#3*>y zn1H`z@xic)(ldPjB_gX+H+p2Vs<20z*zkfA2I+y!WjIi4fmLaqNS+*w2D-4VP-nf?{{H`D zf(HaZ;P?cVY3=&8RX6Wqa%XKPO-k9Ci=p9&w9n`vhK0ASm#-XoaYnk1M3~j<$cXU0|5{K0T2KI5C8!X009sH z0TA#AjGIDbQBNDuoKQR1jg1}3n?@8F( zp@sWj1-f*8k&((`uF(zqZ9Pf!Gd)tq#E}xN9P-2N_iRhQ1-&YR1(`d>XmelpXDQ|s zIKMUt2fU4L3=6)Z?%ehI+$h6P6-DV3p-%VW%&U5{g1OBwy-7Y}e}x@ocxUTLEDO(F zOh=^~^~|OBp-dIO#d$fUH{(%fZF^@#T)oY%fwg%z*T! + ServerName {{ vhost.servername }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Options {{ vhost.documentrootoptions|default( "none" ) }} + Require all granted + + +{% endfor %} \ No newline at end of file diff --git a/17.3_variable/myapache3/tests/inventory b/17.3_variable/myapache3/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/17.3_variable/myapache3/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/17.3_variable/myapache3/tests/test.yml b/17.3_variable/myapache3/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/17.3_variable/myapache3/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/17.3_variable/myapache3/vars/.main.yml.swp b/17.3_variable/myapache3/vars/.main.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..fa7436b3401e5b08c987c046c33ee702f9655e89 GIT binary patch literal 12288 zcmeI&KTZNc6bA5zJ!td-qb7E+2qc=-&dS0>3oUHO2!m|0yR(@YK^pZA9>jPFTPh1} zy@Qp7Z)E{RA{r}_Z<8quk0NCt7K7lpr>j~WO-;6DO+s#Z43=?d#>t72vO_&S~gP{wEz>T_SDN4!0L z^4iWNP48o%?%Fz%w$w6p9^rD?Xeeu^)elC#P58Whwnw+y diff --git a/20_conditions/myapache4/defaults/main.yml b/20_conditions/myapache4/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/20_conditions/myapache4/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/20_conditions/myapache4/files/index.html b/20_conditions/myapache4/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/20_conditions/myapache4/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/20_conditions/myapache4/handlers/main.yml b/20_conditions/myapache4/handlers/main.yml new file mode 100644 index 0000000..c72410b --- /dev/null +++ b/20_conditions/myapache4/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: httpd + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/20_conditions/myapache4/meta/main.yml b/20_conditions/myapache4/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/20_conditions/myapache4/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/20_conditions/myapache4/tasks/main.yml b/20_conditions/myapache4/tasks/main.yml new file mode 100644 index 0000000..867ef6f --- /dev/null +++ b/20_conditions/myapache4/tasks/main.yml @@ -0,0 +1,55 @@ +--- +# tasks file for myapache +- name: import distribution specific variables + include_vars: "{{ ansible_distribution|lower }}.yml" + +- name: install apache + tags: httpd + package: + name: "{{ package_name }}" + state: latest + +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: "{{ apache_conf_dir }}/vhost.conf" + mode: 0640 + owner: root + group: "{{ apache_group }}" + +- name: activate apache + tags: httpd + service: + name: "{{ service_name }}" + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + when: ansible_distribution|lower != "debian" + +- name: create documentroot + tags: httpd + file: + name: "{{ item.documentroot }}" + state: directory + with_items: + - "{{ apache_vhosts }}" + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "{{ item.documentroot }}/index.html" + mode: 0644 + with_items: + - "{{ apache_vhosts }}" \ No newline at end of file diff --git a/20_conditions/myapache4/templates/vhost.conf.jj b/20_conditions/myapache4/templates/vhost.conf.jj new file mode 100644 index 0000000..062c1c3 --- /dev/null +++ b/20_conditions/myapache4/templates/vhost.conf.jj @@ -0,0 +1,19 @@ +{% for vhost in apache_vhosts %} + + ServerName {{ vhost.servername|lower }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Options {{ vhost.documentrootoptions|default( "none" ) }} + Require all granted + + +{% endfor %} \ No newline at end of file diff --git a/20_conditions/myapache4/tests/inventory b/20_conditions/myapache4/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/20_conditions/myapache4/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/20_conditions/myapache4/tests/test.yml b/20_conditions/myapache4/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/20_conditions/myapache4/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/20_conditions/myapache4/vars/centos.yml b/20_conditions/myapache4/vars/centos.yml new file mode 120000 index 0000000..ba2f905 --- /dev/null +++ b/20_conditions/myapache4/vars/centos.yml @@ -0,0 +1 @@ +redhat.yml \ No newline at end of file diff --git a/20_conditions/myapache4/vars/debian.yml b/20_conditions/myapache4/vars/debian.yml new file mode 100644 index 0000000..03ceb9d --- /dev/null +++ b/20_conditions/myapache4/vars/debian.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/apache2/sites-enabled +apache_log_dir: /var/log/apache2 +package_name: apache2 +service_name: apache2 +apache_user: www-data +apache_group: www-data diff --git a/20_conditions/myapache4/vars/main.yml b/20_conditions/myapache4/vars/main.yml new file mode 100644 index 0000000..1fb822e --- /dev/null +++ b/20_conditions/myapache4/vars/main.yml @@ -0,0 +1,15 @@ +--- +# vars file for myapache +http_port: 80 +apache_vhosts: +- servername: ORSYS.Fr + serveralias: www.orsys.fr + documentroot: /var/www/html/orsys.fr + accesslog: "{{ apache_log_dir }}/access_orsys.fr_log" + errorlog: "{{ apache_log_dir }}/error_orsys.fr_log" +- servername: thomas.fr + serveralias: www.thomas.fr + documentroot: /var/www/html/thomas.fr + accesslog: "{{ apache_log_dir }}/access_thomas.fr_log" + errorlog: "{{ apache_log_dir }}/error_thomas.fr_log" + documentrootoptions: indexes \ No newline at end of file diff --git a/20_conditions/myapache4/vars/redhat.yml b/20_conditions/myapache4/vars/redhat.yml new file mode 100644 index 0000000..c77ed08 --- /dev/null +++ b/20_conditions/myapache4/vars/redhat.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/httpd/conf.d/ +apache_log_dir: /var/log/httpd +package_name: httpd +service_name: httpd +apache_user: apache +apache_group: apache diff --git a/21_myphp/myphp/README.md b/21_myphp/myphp/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/21_myphp/myphp/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/21_myphp/myphp/defaults/main.yml b/21_myphp/myphp/defaults/main.yml new file mode 100644 index 0000000..9edcbb6 --- /dev/null +++ b/21_myphp/myphp/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myphp \ No newline at end of file diff --git a/21_myphp/myphp/handlers/main.yml b/21_myphp/myphp/handlers/main.yml new file mode 100644 index 0000000..8b10e1b --- /dev/null +++ b/21_myphp/myphp/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for myphp \ No newline at end of file diff --git a/21_myphp/myphp/meta/main.yml b/21_myphp/myphp/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/21_myphp/myphp/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/21_myphp/myphp/tasks/main.yml b/21_myphp/myphp/tasks/main.yml new file mode 100644 index 0000000..a54d17b --- /dev/null +++ b/21_myphp/myphp/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# tasks file for myphp +- name: import distribution specific variables + tags: php + include_vars: "{{ ansible_distribution|lower }}.yml" + +- name: install php modules + tags: php + package: + name: "{{ item }}" + state: latest + with_items: + "{{ packages_list }}" \ No newline at end of file diff --git a/21_myphp/myphp/tests/inventory b/21_myphp/myphp/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/21_myphp/myphp/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/21_myphp/myphp/tests/test.yml b/21_myphp/myphp/tests/test.yml new file mode 100644 index 0000000..19ca46b --- /dev/null +++ b/21_myphp/myphp/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myphp \ No newline at end of file diff --git a/21_myphp/myphp/vars/centos.yml b/21_myphp/myphp/vars/centos.yml new file mode 100644 index 0000000..f541bdc --- /dev/null +++ b/21_myphp/myphp/vars/centos.yml @@ -0,0 +1,6 @@ + +--- +# distribution dependent vars file for myphp +packages_list: + - php-gd + - php-pdo \ No newline at end of file diff --git a/21_myphp/myphp/vars/debian.yml b/21_myphp/myphp/vars/debian.yml new file mode 100644 index 0000000..db0ab0f --- /dev/null +++ b/21_myphp/myphp/vars/debian.yml @@ -0,0 +1,6 @@ + +--- +# distribution dependent vars file for myphp +packages_list: + - php-gd + - php-mysql \ No newline at end of file diff --git a/21_myphp/myphp/vars/main.yml b/21_myphp/myphp/vars/main.yml new file mode 100644 index 0000000..9fb745b --- /dev/null +++ b/21_myphp/myphp/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for myphp \ No newline at end of file diff --git a/21_myphp/myphp/vars/redhat.yml b/21_myphp/myphp/vars/redhat.yml new file mode 100644 index 0000000..f541bdc --- /dev/null +++ b/21_myphp/myphp/vars/redhat.yml @@ -0,0 +1,6 @@ + +--- +# distribution dependent vars file for myphp +packages_list: + - php-gd + - php-pdo \ No newline at end of file diff --git a/21_myphp/php.yml b/21_myphp/php.yml new file mode 100644 index 0000000..f73d1fd --- /dev/null +++ b/21_myphp/php.yml @@ -0,0 +1,9 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + roles: + - myapache4 + - myphp + diff --git a/23_prompts/apache.yml b/23_prompts/apache.yml new file mode 100644 index 0000000..a67b2cd --- /dev/null +++ b/23_prompts/apache.yml @@ -0,0 +1,11 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + vars_prompt: + - name: httpasswd + prompt: htpasswd protected area password + private: yes + roles: + - myapache5 diff --git a/23_prompts/myapache5/README.md b/23_prompts/myapache5/README.md new file mode 100644 index 0000000..4b2f3e0 --- /dev/null +++ b/23_prompts/myapache5/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Rôle de deploiement apache sur une centos. + +1 seul vhost + +Requirements +------------ + +None + +Role Variables +-------------- + +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log + +Dependencies +------------ + +None + +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: + - { myapache } + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/23_prompts/myapache5/defaults/main.yml b/23_prompts/myapache5/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/23_prompts/myapache5/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/23_prompts/myapache5/files/index.html b/23_prompts/myapache5/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/23_prompts/myapache5/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/23_prompts/myapache5/handlers/main.yml b/23_prompts/myapache5/handlers/main.yml new file mode 100644 index 0000000..2a19def --- /dev/null +++ b/23_prompts/myapache5/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: "{{ service_name }}" + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/23_prompts/myapache5/meta/main.yml b/23_prompts/myapache5/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/23_prompts/myapache5/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/23_prompts/myapache5/tasks/main.yml b/23_prompts/myapache5/tasks/main.yml new file mode 100644 index 0000000..45967f6 --- /dev/null +++ b/23_prompts/myapache5/tasks/main.yml @@ -0,0 +1,71 @@ +--- +# tasks file for myapache +- name: import distribution specific variables + tags: http + include_vars: "{{ ansible_distribution|lower }}.yml" + +- name: install apache + tags: httpd + package: + name: "{{ package_name }}" + state: latest + +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: "{{ apache_conf_dir }}/vhost.conf" + mode: 0640 + owner: root + group: "{{ apache_group }}" + +- name: activate apache + tags: httpd + service: + name: "{{ service_name }}" + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + when: ansible_distribution|lower != "debian" + +- name: create documentroot + tags: httpd + file: + name: "{{ item.documentroot }}" + state: directory + with_items: + - "{{ apache_vhosts }}" + +- name: install python passlib package + tags: req,httpd + package: + name: python-passlib + state: latest + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "{{ item.documentroot }}/index.html" + mode: 0644 + with_items: + - "{{ apache_vhosts }}" + +- name: passwd file + htpasswd: + path: "{{ apache_conf_dir }}/passwd" + name: tom + password: "{{ httpasswd }}" + mode: 0640 + owner: root + group: "{{ apache_group }}" \ No newline at end of file diff --git a/23_prompts/myapache5/templates/vhost.conf.jj b/23_prompts/myapache5/templates/vhost.conf.jj new file mode 100644 index 0000000..be39939 --- /dev/null +++ b/23_prompts/myapache5/templates/vhost.conf.jj @@ -0,0 +1,28 @@ +{% for vhost in apache_vhosts %} + + ServerName {{ vhost.servername|lower }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Options {{ vhost.documentrootoptions|default( "none" ) }} + Require all granted + + + Alias /private /usr/share/doc + + Options indexes + AuthName "stop" + AuthType Basic + AuthUserFile {{ apache_conf_dir }}/passwd + require valid-user + + +{% endfor %} \ No newline at end of file diff --git a/23_prompts/myapache5/tests/inventory b/23_prompts/myapache5/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/23_prompts/myapache5/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/23_prompts/myapache5/tests/test.yml b/23_prompts/myapache5/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/23_prompts/myapache5/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/23_prompts/myapache5/vars/centos.yml b/23_prompts/myapache5/vars/centos.yml new file mode 120000 index 0000000..ba2f905 --- /dev/null +++ b/23_prompts/myapache5/vars/centos.yml @@ -0,0 +1 @@ +redhat.yml \ No newline at end of file diff --git a/23_prompts/myapache5/vars/debian.yml b/23_prompts/myapache5/vars/debian.yml new file mode 100644 index 0000000..03ceb9d --- /dev/null +++ b/23_prompts/myapache5/vars/debian.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/apache2/sites-enabled +apache_log_dir: /var/log/apache2 +package_name: apache2 +service_name: apache2 +apache_user: www-data +apache_group: www-data diff --git a/23_prompts/myapache5/vars/main.yml b/23_prompts/myapache5/vars/main.yml new file mode 100644 index 0000000..1fb822e --- /dev/null +++ b/23_prompts/myapache5/vars/main.yml @@ -0,0 +1,15 @@ +--- +# vars file for myapache +http_port: 80 +apache_vhosts: +- servername: ORSYS.Fr + serveralias: www.orsys.fr + documentroot: /var/www/html/orsys.fr + accesslog: "{{ apache_log_dir }}/access_orsys.fr_log" + errorlog: "{{ apache_log_dir }}/error_orsys.fr_log" +- servername: thomas.fr + serveralias: www.thomas.fr + documentroot: /var/www/html/thomas.fr + accesslog: "{{ apache_log_dir }}/access_thomas.fr_log" + errorlog: "{{ apache_log_dir }}/error_thomas.fr_log" + documentrootoptions: indexes \ No newline at end of file diff --git a/23_prompts/myapache5/vars/redhat.yml b/23_prompts/myapache5/vars/redhat.yml new file mode 100644 index 0000000..c77ed08 --- /dev/null +++ b/23_prompts/myapache5/vars/redhat.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/httpd/conf.d/ +apache_log_dir: /var/log/httpd +package_name: httpd +service_name: httpd +apache_user: apache +apache_group: apache diff --git a/25_vaults/apache.yml b/25_vaults/apache.yml new file mode 100644 index 0000000..5836d03 --- /dev/null +++ b/25_vaults/apache.yml @@ -0,0 +1,7 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: formation + become: true + roles: + - myapache diff --git a/25_vaults/myapache/README.md b/25_vaults/myapache/README.md new file mode 100644 index 0000000..4b2f3e0 --- /dev/null +++ b/25_vaults/myapache/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Rôle de deploiement apache sur une centos. + +1 seul vhost + +Requirements +------------ + +None + +Role Variables +-------------- + +http_port: 80 +servername: orsys.fr +serveralias: "www.{{ servername }}" +documentroot: /var/www/html/orsys.fr +accesslog: /var/log/httpd/access_orsys.fr_log +errorlog: /var/log/httpd/error_orsys.fr_log + +Dependencies +------------ + +None + +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: + - { myapache } + +License +------- + +BSD + +Author Information +------------------ + +Thomas Constans diff --git a/25_vaults/myapache/defaults/main.yml b/25_vaults/myapache/defaults/main.yml new file mode 100644 index 0000000..8c667e1 --- /dev/null +++ b/25_vaults/myapache/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for myapache \ No newline at end of file diff --git a/25_vaults/myapache/files/index.html b/25_vaults/myapache/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/25_vaults/myapache/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/25_vaults/myapache/handlers/main.yml b/25_vaults/myapache/handlers/main.yml new file mode 100644 index 0000000..2a19def --- /dev/null +++ b/25_vaults/myapache/handlers/main.yml @@ -0,0 +1,11 @@ +--- +# handlers file for myapache +- name: reload httpd + service: + name: "{{ service_name }}" + state: reloaded + +- name: reload firewalld + service: + name: firewalld + state: reloaded diff --git a/25_vaults/myapache/meta/main.yml b/25_vaults/myapache/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/25_vaults/myapache/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + 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: 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/25_vaults/myapache/tasks/main.yml b/25_vaults/myapache/tasks/main.yml new file mode 100644 index 0000000..de74724 --- /dev/null +++ b/25_vaults/myapache/tasks/main.yml @@ -0,0 +1,75 @@ +--- +# tasks file for myapache +- name: import distribution specific variables + tags: http + include_vars: "{{ ansible_distribution|lower }}.yml" + +- name: include sensitive information + tags: http + include_vars: apache_sensitive_data.yml + +- name: install apache + tags: httpd + package: + name: "{{ package_name }}" + state: latest + +- name: conf httpd + tags: httpd + notify: reload httpd + template: + src: vhost.conf.jj + dest: "{{ apache_conf_dir }}/vhost.conf" + mode: 0640 + owner: root + group: "{{ apache_group }}" + +- name: activate apache + tags: httpd + service: + name: "{{ service_name }}" + enabled: yes + state: restarted + +- name: open firewall port + tags: httpd + firewalld: + service: http + permanent: yes + immediate: yes + state: enabled + ignore_errors: yes + notify: reload firewalld + when: ansible_distribution|lower != "debian" + +- name: create documentroot + tags: httpd + file: + name: "{{ item.documentroot }}" + state: directory + with_items: + - "{{ apache_vhosts }}" + +- name: install python passlib package + tags: req,httpd + package: + name: python-passlib + state: latest + +- name: create index file + tags: httpd + copy: + src: index.html + dest: "{{ item.documentroot }}/index.html" + mode: 0644 + with_items: + - "{{ apache_vhosts }}" + +- name: passwd file + htpasswd: + path: "{{ apache_conf_dir }}/passwd" + name: tom + password: "{{ httpasswd }}" + mode: 0640 + owner: root + group: "{{ apache_group }}" \ No newline at end of file diff --git a/25_vaults/myapache/templates/vhost.conf.jj b/25_vaults/myapache/templates/vhost.conf.jj new file mode 100644 index 0000000..be39939 --- /dev/null +++ b/25_vaults/myapache/templates/vhost.conf.jj @@ -0,0 +1,28 @@ +{% for vhost in apache_vhosts %} + + ServerName {{ vhost.servername|lower }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + + + Options {{ vhost.documentrootoptions|default( "none" ) }} + Require all granted + + + Alias /private /usr/share/doc + + Options indexes + AuthName "stop" + AuthType Basic + AuthUserFile {{ apache_conf_dir }}/passwd + require valid-user + + +{% endfor %} \ No newline at end of file diff --git a/25_vaults/myapache/tests/inventory b/25_vaults/myapache/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/25_vaults/myapache/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/25_vaults/myapache/tests/test.yml b/25_vaults/myapache/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/25_vaults/myapache/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/25_vaults/myapache/vars/apache_sensitive_data.yml b/25_vaults/myapache/vars/apache_sensitive_data.yml new file mode 100644 index 0000000..782663b --- /dev/null +++ b/25_vaults/myapache/vars/apache_sensitive_data.yml @@ -0,0 +1,6 @@ +$ANSIBLE_VAULT;1.1;AES256 +31653731393732623239623030633932666534613931666630313335346338306362356263366261 +6465393132643537613161343263613530656263623236390a633835613663643464313930613562 +31306535323538633664393032386665396239626563343736636266333436336265386639323035 +6530326539336236320a613631653861303464353066353961383738396639313831323065623639 +32663763333138613435653438363734343739303838303232313337313230646364 diff --git a/25_vaults/myapache/vars/centos.yml b/25_vaults/myapache/vars/centos.yml new file mode 120000 index 0000000..ba2f905 --- /dev/null +++ b/25_vaults/myapache/vars/centos.yml @@ -0,0 +1 @@ +redhat.yml \ No newline at end of file diff --git a/25_vaults/myapache/vars/debian.yml b/25_vaults/myapache/vars/debian.yml new file mode 100644 index 0000000..03ceb9d --- /dev/null +++ b/25_vaults/myapache/vars/debian.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/apache2/sites-enabled +apache_log_dir: /var/log/apache2 +package_name: apache2 +service_name: apache2 +apache_user: www-data +apache_group: www-data diff --git a/25_vaults/myapache/vars/main.yml b/25_vaults/myapache/vars/main.yml new file mode 100644 index 0000000..1fb822e --- /dev/null +++ b/25_vaults/myapache/vars/main.yml @@ -0,0 +1,15 @@ +--- +# vars file for myapache +http_port: 80 +apache_vhosts: +- servername: ORSYS.Fr + serveralias: www.orsys.fr + documentroot: /var/www/html/orsys.fr + accesslog: "{{ apache_log_dir }}/access_orsys.fr_log" + errorlog: "{{ apache_log_dir }}/error_orsys.fr_log" +- servername: thomas.fr + serveralias: www.thomas.fr + documentroot: /var/www/html/thomas.fr + accesslog: "{{ apache_log_dir }}/access_thomas.fr_log" + errorlog: "{{ apache_log_dir }}/error_thomas.fr_log" + documentrootoptions: indexes \ No newline at end of file diff --git a/25_vaults/myapache/vars/redhat.yml b/25_vaults/myapache/vars/redhat.yml new file mode 100644 index 0000000..c77ed08 --- /dev/null +++ b/25_vaults/myapache/vars/redhat.yml @@ -0,0 +1,7 @@ +--- +apache_conf_dir: /etc/httpd/conf.d/ +apache_log_dir: /var/log/httpd +package_name: httpd +service_name: httpd +apache_user: apache +apache_group: apache diff --git a/ansible.png b/ansible.png new file mode 100644 index 0000000000000000000000000000000000000000..ff294e3fd965ca5f356abb0712e6d2a137d21e15 GIT binary patch literal 5164 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