-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ca2ec4
commit cbcd226
Showing
22 changed files
with
442 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# defaults file for backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# handlers file for backend | ||
- name: Reload systemd | ||
ansible.builtin.systemd: | ||
daemon_reload: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: Clone a Git repository | ||
ansible.builtin.git: | ||
repo: https://github.com/sshresthadh/devops-class.git | ||
dest: /home/ubuntu/test | ||
version: main | ||
|
||
- name: Install the gpg key for nodejs LTS | ||
apt_key: | ||
url: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key" | ||
state: present | ||
|
||
- name: Install the nodejs LTS repos | ||
apt_repository: | ||
repo: "deb https://deb.nodesource.com/node_14.x focal main" | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Install the nodejs | ||
apt: | ||
name: nodejs | ||
state: present | ||
|
||
- name: NPM Install | ||
shell: > | ||
cd /home/ubuntu/test/all_in_docker/server | ||
npm i | ||
- name: Create systemd service file | ||
ansible.builtin.template: | ||
src: backend.j2 # Path to your systemd service template file | ||
dest: /etc/systemd/system/backend.service | ||
notify: Reload systemd | ||
|
||
- name: Start and enable the service | ||
ansible.builtin.service: | ||
name: backend | ||
state: started | ||
enabled: yes | ||
notify: Reload systemd | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[Unit] | ||
|
||
Description=Your Node.js Backend | ||
|
||
After=network.target | ||
|
||
|
||
|
||
[Service] | ||
|
||
Environment=NODE_ENV=production | ||
|
||
ExecStart=/usr/bin/node index.js | ||
|
||
WorkingDirectory=/home/ubuntu/devops-class/all_in_docker/server | ||
|
||
Restart=always | ||
|
||
RestartSec=10 | ||
|
||
StandardOutput=syslog | ||
|
||
StandardError=syslog | ||
|
||
SyslogIdentifier=client | ||
|
||
|
||
|
||
[Install] | ||
|
||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: localhost | ||
remote_user: root | ||
roles: | ||
- backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# vars file for backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#defining variables | ||
--- | ||
download_url: "https://github.com/grafana/agent/releases/download/v{{ agent_version }}/agent-{{ linux_architecture }}.zip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- name: Add the Grafana GPG key and APT repository | ||
become: yes | ||
shell: | | ||
curl https://packages.grafana.com/gpg.key | sudo apt-key add - | ||
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" --yes | ||
- name: Update apt | ||
apt: | ||
update_cache: yes | ||
|
||
- name: Install grafana through apt | ||
ansible.builtin.apt: | ||
name: grafana | ||
state: latest | ||
install_recommends: yes | ||
|
||
- name: Reload the SystemD to re-read configurations and start grafana | ||
become: yes | ||
systemd: | ||
daemon-reload: yes | ||
name: grafana-server | ||
enabled: yes | ||
state: started | ||
|
||
- name: set nginx conf file for prometheus | ||
become: true | ||
ansible.builtin.template: | ||
src: grafana-conf.j2 | ||
dest: /etc/nginx/sites-enabled/grafana.conf | ||
|
||
- name: restart nginx | ||
service: | ||
name: nginx | ||
state: restarted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
server { | ||
server_name grafana.deerhold.com; | ||
|
||
location / { | ||
proxy_set_header Host $http_host; | ||
proxy_pass http://localhost:3000/; | ||
} | ||
|
||
listen [::]:443 ssl ipv6only=on; # managed by Certbot | ||
listen 443 ssl; # managed by Certbot | ||
ssl_certificate /etc/letsencrypt/live/grafana.deerhold.com-0001/fullchain.pem; # managed by Certbot | ||
ssl_certificate_key /etc/letsencrypt/live/grafana.deerhold.com-0001/privkey.pem; # managed by Certbot | ||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | ||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | ||
|
||
} | ||
server { | ||
if ($host = grafana.deerhold.com) { | ||
return 301 https://$host$request_uri; | ||
} # managed by Certbot | ||
|
||
|
||
listen 80; | ||
listen [::]:80; | ||
server_name grafana.deerhold.com; | ||
return 404; # managed by Certbot | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Restart mysql | ||
service: | ||
name: mysql | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- name: restart nginx | ||
service: | ||
name: nginx | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
- name: start nginx | ||
service: | ||
name: nginx | ||
state: started | ||
state: stopped | ||
notify: restart nginx | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#defining variables | ||
--- | ||
prometheus_version: "2.31" | ||
download_url: "https://github.com/prometheus/prometheus/releases/download/v2.31.0/prometheus-2.31.0.linux-amd64.tar.gz" |
Oops, something went wrong.