diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed9e9c7c49920298e382cf466d9d9a32a088243b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,36 @@ +stages: + - build + - Config + - deploy +# TInstall the base Configuration. +Configuration_base: + stage: build + script: + - ansible-playbook -i inventory.ini main.yml --ask-vault-pass +# Upgrade packages. +Upgrade: + stage: build + script: + - ansible-playbook -i inventory.ini upgrade.yml --ask-vault-pass + +# Configure docker +Configuration_docker: + stage: Config + script: + - ansible-playbook -i inventory.ini Config.yml --ask-vault-pass +# Configure nginx +Configuration_nginx: + stage: Config + script: + - ansible-playbook -i inventory.ini nginx.yml --ask-vault-pass +# Configure postgreSQL +Configuration_postgreSQL: + stage: Config + script: + - ansible-playbook -i inventory.ini postgresql.yml --ask-vault-pass + +# Deploy the synapse app. +Configuration_Synapse: + stage: deploy + script: + - ansible-playbook -i inventory.ini synapse.yml --ask-vault-pass \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..878ec9e6136015beb440430e4ae7c0a5d1258578 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "ansible.python.interpreterPath": "/usr/local/bin/python3" +} \ No newline at end of file diff --git a/group_vars/all.yml b/group_vars/all.yml index ee5eebdae34e95eff10cd9de69d81b13f678b5be..f8f5ce956106b15960953cf43bae8e2cce68ec4c 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -11,7 +11,5 @@ docker_apt_arch: "{{ arch }}" root_user: default_root_keys: - - name: thomas-ed25519 - key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPrw78OSJACq5MFXHrhAr2bPpnTNxwLE85mzij8gKmCs thomas@thonkpad - name: g7_key-ed25519 - key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFH+M4GLKYVf/hThCQ+DwJXYqEb7THVkfqqnVh32DAOI pifou@zabeth11 + key: <Your ed25519 public key> diff --git a/inventory.ini b/inventory.ini index 2415171cabb1c073676d921bba651a1c09947c57..aa00ac43a03c02873e697ef967341ea5845a563c 100644 --- a/inventory.ini +++ b/inventory.ini @@ -1,10 +1,10 @@ [all] # Replace this with your hostname and IP address -172.26.145.114 -172.26.145.115 +<The IP address of your PostgreSQL Database VM> +<The IP address of your Synapse webserver VM> [db] -172.26.145.114 +<The IP address of your PostgreSQL Database VM> [synapse] -172.26.145.115 +<The IP address of your Synapse webserver VM> \ No newline at end of file diff --git a/playbooks/matrix.conf.j2 b/playbooks/matrix.conf.j2 index 63d117986ad8b6fd8d6671741290c4c8b667d06c..ccc5c73f28cea05560c719d414cf35c82b310f82 100644 --- a/playbooks/matrix.conf.j2 +++ b/playbooks/matrix.conf.j2 @@ -1,6 +1,6 @@ server { listen 443 ssl; - server_name synapse.nyala.website; + server_name <Your synapse web server>; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA; @@ -8,8 +8,8 @@ server { ssl_session_cache shared:SSL:10m; ssl_session_tickets off; - ssl_certificate /etc/letsencrypt/live/synapse.nyala.website-0001/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/synapse.nyala.website-0001/privkey.pem; + ssl_certificate <Your Certifact SSL>; + ssl_certificate_key <Your private TLS key>; location / { proxy_pass http://127.0.0.1:8008; diff --git a/playbooks/nginx_install.yml b/playbooks/nginx_install.yml index cc2071de5c24455694a249e95e930af59f4d958a..8a82a02305771a5275d6503ebbb5427e00cb596b 100644 --- a/playbooks/nginx_install.yml +++ b/playbooks/nginx_install.yml @@ -1,20 +1,6 @@ -- hosts: all - tasks: - # Install nginx et assurer la dernière version. - - name: ensure nginx is at the latest version - apt: name=nginx state=latest - # Start nginx on the machine - - name: start nginx - service: - name: nginx - state: started - # Push the nginx server configuration file - - name: Upload the file of configuration to the nginx server. - copy: - src: matrix.conf.j2 - dest: /etc/nginx/sites-enabled/matrix - # Restart nginx server - - name: Restart nginx server. - service: - name: nginx - state: restarted +--- +# Cette playbook c'est pour installer la base de donner PostgreSQL sur la machine db +- name: "Install and configure nginx web server" + hosts: synapse + roles: + - nginx \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6fe959406121db92df6aaa550b1622187d1ee854..85c2ad28a63d4cdf5e3c3880eb5711e41f64897a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,4 +30,4 @@ ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 subprocess-tee==0.4.1 wcmatch==8.5 -yamllint==1.35.1 +yamllint==1.35.1 \ No newline at end of file diff --git a/roles/nginx/README.md b/roles/nginx/README.md new file mode 100644 index 0000000000000000000000000000000000000000..225dd44b9fc5b3abff7e9c68ff9e91d505cdd5f0 --- /dev/null +++ b/roles/nginx/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/roles/nginx/defaults/main.yml b/roles/nginx/defaults/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..a28e129f1095566fdffba0493544b23582a2f7a0 --- /dev/null +++ b/roles/nginx/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for roles/nginx diff --git a/roles/nginx/handlers/main.yml b/roles/nginx/handlers/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..d3543255a3a85f970d49e74ec9d1c894c61b8957 --- /dev/null +++ b/roles/nginx/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for roles/nginx diff --git a/roles/nginx/meta/main.yml b/roles/nginx/meta/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..c572acc9f8b466bea50f2799b0ca1956418b862c --- /dev/null +++ b/roles/nginx/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..83ab03c6ccf1b1f8932c1927290a718e56e6eb07 --- /dev/null +++ b/roles/nginx/tasks/main.yml @@ -0,0 +1,19 @@ +--- +# Install nginx et assurer la dernière version. +- name: ensure nginx is at the latest version + apt: name=nginx state=latest +# Start nginx on the machine +- name: start nginx + service: + name: nginx + state: started +# Push the nginx server configuration file +- name: Upload the file of configuration to the nginx server. + copy: + src: matrix.conf.j2 + dest: /etc/nginx/sites-enabled/matrix +# Restart nginx server +- name: Restart nginx server. + service: + name: nginx + tate: restarted \ No newline at end of file diff --git a/roles/nginx/tests/inventory b/roles/nginx/tests/inventory new file mode 100644 index 0000000000000000000000000000000000000000..878877b0776c44f55fc4e458f70840f31da5bb01 --- /dev/null +++ b/roles/nginx/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/nginx/tests/test.yml b/roles/nginx/tests/test.yml new file mode 100644 index 0000000000000000000000000000000000000000..6750534da0ca625453e2be49bdf8b609c1b472e2 --- /dev/null +++ b/roles/nginx/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - roles/nginx diff --git a/roles/nginx/vars/main.yml b/roles/nginx/vars/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..4d5dfe2d7070ece30cc7e66450018a9358b53852 --- /dev/null +++ b/roles/nginx/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for roles/nginx