diff --git a/cookbooks/gitea/attributes.rb b/cookbooks/gitea/attributes.rb deleted file mode 100644 index 618852a..0000000 --- a/cookbooks/gitea/attributes.rb +++ /dev/null @@ -1,18 +0,0 @@ -# ------------------------------------------- -# Specifying the default settings: -# ------------------------------------------- -node.reverse_merge!({ - 'gitea' => { - 'url' => 'https://github.com/go-gitea/gitea/releases/download/', - 'prefix' => 'gitea-', - 'postfix' => '-linux-amd64', - 'storage' => '/opt/gitea/', - 'location' => '/usr/local/bin/' - }, - 'go-mmproxy' => { - 'url' => 'https://github.com/path-network/go-mmproxy/releases/', - 'bin_url' => 'https://github.com/path-network/go-mmproxy/releases/download/2.0/go-mmproxy-2.0-centos8-x86_64', - 'storage' => '/opt/go-mmproxy/', - 'location' => '/usr/local/bin/' - }, -}) diff --git a/cookbooks/gitea/default.rb b/cookbooks/gitea/default.rb deleted file mode 100644 index 273cc08..0000000 --- a/cookbooks/gitea/default.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Loading the attributes: -include_recipe './attributes.rb' - -# Install: -include_recipe './install-go-mmproxy.rb' - -# Setup: -include_recipe './setup-go-mmproxy.rb' diff --git a/cookbooks/gitea/files/etc/consul.d/service-go-mmproxy.json b/cookbooks/gitea/files/etc/consul.d/service-go-mmproxy.json deleted file mode 100644 index f45b065..0000000 --- a/cookbooks/gitea/files/etc/consul.d/service-go-mmproxy.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "service": { - "name": "go-mmproxy", - "port": 50021, - "check":{ - "tcp": "localhost:50021", - "interval": "60s", - "timeout": "1s", - "success_before_passing": 3 - } - } -} diff --git a/cookbooks/gitea/files/etc/systemd/system/go-mmproxy.service b/cookbooks/gitea/files/etc/systemd/system/go-mmproxy.service deleted file mode 100644 index cc14caf..0000000 --- a/cookbooks/gitea/files/etc/systemd/system/go-mmproxy.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=go-mmproxy -After=network.target - -[Service] -Type=simple -LimitNOFILE=65535 -ExecStartPost=/sbin/ip rule add from 127.0.0.1/8 iif lo table 123 -ExecStartPost=/sbin/ip route add local 0.0.0.0/0 dev lo table 123 -ExecStart=/usr/local/bin/go-mmproxy -l 0.0.0.0:50021 -4 127.0.0.1:10022 -v 2 -ExecStopPost=/sbin/ip rule del from 127.0.0.1/8 iif lo table 123 -ExecStopPost=/sbin/ip route del local 0.0.0.0/0 dev lo table 123 -Restart=on-failure -RestartSec=10s - -[Install] -WantedBy=multi-user.target diff --git a/cookbooks/gitea/files/etc/systemd/system/promtail-gitea.service b/cookbooks/gitea/files/etc/systemd/system/promtail-gitea.service deleted file mode 100644 index e1380bd..0000000 --- a/cookbooks/gitea/files/etc/systemd/system/promtail-gitea.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Grafana Promtail -Documentation=https://github.com/grafana/loki -After=network-online.target - -[Service] -User=root -Restart=always -ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/gitea.yaml - -[Install] -WantedBy=multi-user.target diff --git a/cookbooks/gitea/install-go-mmproxy.rb b/cookbooks/gitea/install-go-mmproxy.rb deleted file mode 100644 index 5ccf64c..0000000 --- a/cookbooks/gitea/install-go-mmproxy.rb +++ /dev/null @@ -1,29 +0,0 @@ -# Download: -TMP = "/tmp/go-mmproxy" - -execute "wget #{node['go-mmproxy']['bin_url']} -O #{TMP}" do - not_if "test -e #{node['go-mmproxy']['storage']}/go-mmproxy" -end - -# Install: -directory node['go-mmproxy']['storage'] do - owner 'root' - group 'root' - mode '755' -end - -execute "mv #{TMP} #{node['go-mmproxy']['storage']}/go-mmproxy" do - not_if "test -e #{node['go-mmproxy']['storage']}/go-mmproxy" -end - -# Change Owner and Permissions: -file "#{node['go-mmproxy']['storage']}/go-mmproxy" do - owner 'root' - group 'root' - mode '755' -end - -# Create Link -link "#{node['go-mmproxy']['location']}/go-mmproxy" do - to "#{node['go-mmproxy']['storage']}/go-mmproxy" -end diff --git a/cookbooks/gitea/setup-go-mmproxy.rb b/cookbooks/gitea/setup-go-mmproxy.rb deleted file mode 100644 index 2006378..0000000 --- a/cookbooks/gitea/setup-go-mmproxy.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Deploy `supervisord` config`: -remote_file '/etc/systemd/system/go-mmproxy.service' do - owner 'root' - group 'root' - mode '644' - - notifies :restart, 'service[go-mmproxy]' -end - -service 'go-mmproxy' do - action [ :enable, :restart ] -end - -# Depoy `consul` service configuration for `gitea`: -remote_file '/etc/consul.d/service-go-mmproxy.json' do - owner 'consul' - group 'consul' - mode '644' - - notifies :reload, 'service[consul]' -end - -service 'consul' do - action :nothing -end - -# Firewall settings here: -%w( 50021/tcp ).each do |p| - execute "ufw allow #{p}" do - user 'root' - - not_if "LANG=c ufw status | grep #{p}" - - notifies :run, 'execute[ufw reload-or-enable]' - end -end - -execute 'ufw reload-or-enable' do - user 'root' - command 'LANG=C ufw reload | grep skipping && ufw --force enable || exit 0' - - action :nothing -end diff --git a/cookbooks/gitea/templates/etc/promtail/gitea.yaml b/cookbooks/gitea/templates/etc/promtail/gitea.yaml deleted file mode 100644 index 48d7dd0..0000000 --- a/cookbooks/gitea/templates/etc/promtail/gitea.yaml +++ /dev/null @@ -1,61 +0,0 @@ -server: - disable: true - -positions: - filename: /var/opt/promtail/promtail_gitea_position.yaml - -clients: - - url: http://<%= @LOKIENDPOINT %>/loki/api/v1/push - -scrape_configs: - - job_name: gitea - static_configs: - - targets: - - localhost - labels: - job: gitea - hostname: <%= @HOSTNAME %> - vhost: gitea.kazu634.com - __path__: /var/log/supervisor/gitea.log - - pipeline_stages: - - match: - selector: '{job="gitea"}' - - stages: - - drop: - expression: "(Static|robots.txt|sitemap.xml)" - - - regex: - expression: '^\[Macaron\] (?P[0-9]+\-[0-9]+\-[0-9]+ +[0-9]+:[0-9]+:[0-9]+): (?P[^\/]+) (?P\/[^ ]*) (?P[^ ]+) (?P.+)$' - - - timestamp: - source: timestamp - format: 2006-01-02 15:04:05 - location: Asia/Tokyo - - - template: - source: message - template: '{{ .message1 }} {{ .uri }} ({{ .message2 }})' - - - template: - source: level - template: '{{ .response }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "(2[0-9]+|3[0-9]+|for)" .Value "info" }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "4[0-9]+" .Value "warning" }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "5[0-9]+" .Value "error" }}' - - - labels: - level: - - - output: - source: message diff --git a/cookbooks/prometheus/files/etc/prometheus.d/alerts/services.yml b/cookbooks/prometheus/files/etc/prometheus.d/alerts/services.yml index 20488a6..b929b7c 100644 --- a/cookbooks/prometheus/files/etc/prometheus.d/alerts/services.yml +++ b/cookbooks/prometheus/files/etc/prometheus.d/alerts/services.yml @@ -10,3 +10,12 @@ groups: summary: "Digdag is not running: {{ $labels.instance }}." description: "Digdag is not running: {{ $labels.instance }}." + - alert: go-mmproxy + expr: node_systemd_unit_state{name="go-mmproxy:w.service", state="active"} != 1 + for: 5m + labels: + severity: error + annotations: + summary: "Digdag is not running: {{ $labels.instance }}." + description: "Digdag is not running: {{ $labels.instance }}." +