[tor-commits] [metrics-cloud/master] metrics-common changes

irl at torproject.org irl at torproject.org
Mon Apr 20 15:44:43 UTC 2020


commit 66854108b54338ea98fafbfcf086fb2e395e9f34
Author: Iain R. Learmonth <irl at fsfe.org>
Date:   Wed Apr 1 15:12:20 2020 +0100

    metrics-common changes
---
 ansible/common.yml                                   |  5 -----
 ansible/exit-scanners-aws.yml                        | 12 ++++++------
 ansible/roles/debian-backports/tasks/main.yml        |  6 ------
 ansible/roles/debian-backports/vars/Debian.yml       |  3 ---
 ansible/roles/debian-backports/vars/Ubuntu.yml       |  3 ---
 ansible/roles/debian-backports/vars/main.yml         |  2 --
 ansible/roles/exit-scanner/files/exitscan.py         |  5 +++++
 ansible/roles/exit-scanner/files/exitscanner.service |  1 +
 ansible/roles/sanity/files/vimrc.local               |  2 --
 ansible/roles/sanity/tasks/main.yml                  |  7 -------
 ansible/site.yml                                     |  3 ++-
 cloudformation/exit-scanner-dev.yml                  |  9 +++++++++
 12 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/ansible/common.yml b/ansible/common.yml
deleted file mode 100644
index 6ab3711..0000000
--- a/ansible/common.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-- hosts: all
-  user: admin
-  roles:
-    - sanity
diff --git a/ansible/exit-scanners-aws.yml b/ansible/exit-scanners-aws.yml
index 1d79d12..a4eb657 100644
--- a/ansible/exit-scanners-aws.yml
+++ b/ansible/exit-scanners-aws.yml
@@ -1,8 +1,8 @@
 ---
-- hosts: exit-scanners
-  user: admin
+- hosts: exit_scanners
+  become: true
   roles:
-    - tor-client
-    - exit-scanner-sys
-    - exit-scanner
-    - check
+    - metrics-common
+    #- tor-client
+    #- exit-scanner
+    #- check
diff --git a/ansible/roles/debian-backports/tasks/main.yml b/ansible/roles/debian-backports/tasks/main.yml
deleted file mode 100644
index 51ab50a..0000000
--- a/ansible/roles/debian-backports/tasks/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-- name: add distribution-specific variables
-  include_vars: "{{ ansible_distribution }}.yml"
-- name: add backports repository
-  apt_repository: repo='deb {{ backports_uri }} {{ backports_components }}' state=present update_cache=yes
-  become: true
diff --git a/ansible/roles/debian-backports/vars/Debian.yml b/ansible/roles/debian-backports/vars/Debian.yml
deleted file mode 100644
index 4943727..0000000
--- a/ansible/roles/debian-backports/vars/Debian.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-backports_uri: http://http.debian.net/debian
-backports_components: "{{backports_distribution}}-backports main contrib non-free"
diff --git a/ansible/roles/debian-backports/vars/Ubuntu.yml b/ansible/roles/debian-backports/vars/Ubuntu.yml
deleted file mode 100644
index 6666ac7..0000000
--- a/ansible/roles/debian-backports/vars/Ubuntu.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-backports_uri: http://archive.ubuntu.com/ubuntu
-backports_components: "{{backports_distribution}}-backports main restricted universe multiverse"
diff --git a/ansible/roles/debian-backports/vars/main.yml b/ansible/roles/debian-backports/vars/main.yml
deleted file mode 100644
index 0b79f68..0000000
--- a/ansible/roles/debian-backports/vars/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-backports_distribution: "{{ansible_distribution_release}}"
diff --git a/ansible/roles/exit-scanner/files/exitscan.py b/ansible/roles/exit-scanner/files/exitscan.py
index d6ff874..33fdf22 100644
--- a/ansible/roles/exit-scanner/files/exitscan.py
+++ b/ansible/roles/exit-scanner/files/exitscan.py
@@ -8,6 +8,7 @@ import os
 import os.path
 import re
 import subprocess
+import threading
 
 import stem.descriptor
 
@@ -54,10 +55,13 @@ def run():
             merge(desc)
 
     # Import new measurements
+    kill = lambda process: process.kill()
     with subprocess.Popen(["./bin/exitmap", "ipscan", "-o", "/dev/stdout"],
                           cwd="/srv/tordnsel.torproject.org/exitscanner/exitmap",
                           stdout=subprocess.PIPE,
                           encoding='utf-8') as p:
+        scantimer = threading.Timer(7200, kill, [p])
+        scantimer.start()
         for line in p.stdout:
             print(line)
             result = re.match(
@@ -76,6 +80,7 @@ def run():
                                                 "%Y-%m-%d %H:%M:%S"))
                 ]
                 merge(desc)
+        scantimer.cancel()
 
     # Format exit list filename
     now = datetime.datetime.utcnow()
diff --git a/ansible/roles/exit-scanner/files/exitscanner.service b/ansible/roles/exit-scanner/files/exitscanner.service
index 920a081..806932c 100644
--- a/ansible/roles/exit-scanner/files/exitscanner.service
+++ b/ansible/roles/exit-scanner/files/exitscanner.service
@@ -5,6 +5,7 @@ Description=Exit Scanner
 Type=simple
 WorkingDirectory=/srv/tordnsel.torproject.org
 ExecStart=/usr/bin/python3 /srv/tordnsel.torproject.org/exitscanner/exitscan.py
+StandardOutput=file:/srv/tordnsel.torproject.org/exitscanner.log
 
 [Install]
 WantedBy=default.target
diff --git a/ansible/roles/sanity/files/vimrc.local b/ansible/roles/sanity/files/vimrc.local
deleted file mode 100644
index afd5ae0..0000000
--- a/ansible/roles/sanity/files/vimrc.local
+++ /dev/null
@@ -1,2 +0,0 @@
-let g:skip_defaults_vim = 1
-set mouse=
diff --git a/ansible/roles/sanity/tasks/main.yml b/ansible/roles/sanity/tasks/main.yml
deleted file mode 100644
index 73d7c59..0000000
--- a/ansible/roles/sanity/tasks/main.yml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-- name: install vim defaults
-  become: true
-  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
-  copy:
-    src: vimrc.local
-    dest: /etc/vim/vimrc.local
diff --git a/ansible/site.yml b/ansible/site.yml
index 8691e42..2795690 100644
--- a/ansible/site.yml
+++ b/ansible/site.yml
@@ -1,4 +1,5 @@
 ---
-- import_playbook: common.yml
+- import_playbook: exit-scanners.yml
 - import_playbook: monitors.yml
+- import_playbook: onionoo-backends.yml
 - import_playbook: onionperfs.yml
diff --git a/cloudformation/exit-scanner-dev.yml b/cloudformation/exit-scanner-dev.yml
index 5c126c9..0407996 100644
--- a/cloudformation/exit-scanner-dev.yml
+++ b/cloudformation/exit-scanner-dev.yml
@@ -21,6 +21,15 @@ Resources:
         - Fn::ImportValue: 'MetricsInternetSecurityGroup'
         - Fn::ImportValue: 'MetricsPingableSecurityGroup'
         - Fn::ImportValue: 'MetricsHTTPSSecurityGroup'
+  InstanceDNSName:
+    Type: AWS::Route53::RecordSet
+    Properties:
+      HostedZoneName: tm-dev-aws.safemetrics.org.
+      Name: !Join ['', [!Ref 'AWS::StackName', .tm-dev-aws.safemetrics.org.]]
+      Type: A
+      TTL: '300'
+      ResourceRecords:
+      - !GetAtt Instance.PublicIp
 Outputs:
   PublicIp:
     Description: "Instance public IP"



More information about the tor-commits mailing list