Compare commits

..
23 Commits
Author SHA1 Message Date
Karenzz afd3361766 Checked the port and set the chrome_options 2023-06-19 17:02:41 -04:00
Karenzz 883ec747ce Merge branch 'main' of https://gogs.gtsplab.com:5432/SVIG/pricer 2023-06-19 15:41:58 -04:00
Karenzz f99458570a Changed the zipcode file path 2023-06-19 15:41:33 -04:00
cheezedoodle2 1988a0f7fa Added ansible-lint for syntax checking 2023-06-16 14:16:09 -07:00
cheezedoodle2 104ae2e903 Added note on installing snapd 2023-06-16 14:14:04 -07:00
cheezedoodle2 bdb2a48a86 Use gitignore to ignore packages installed via venv 2023-06-16 14:14:04 -07:00
Karenzz 46e66a20a1 Started snapd.service and installed chromium 2023-06-16 16:41:22 -04:00
Xuanyi Wang 04d148cdab Update 'docker/dev/authorized_keys' 2023-06-16 00:22:11 +02:00
Karenzz 1a1143cec2 Installed Chromium and Chromedriver 2023-06-15 16:59:13 -04:00
cheezedoodle2 1e72e8ce59 Added ansible to list of package requirements 2023-06-14 17:00:54 -07:00
cheezedoodle2 0391614151 Undo test commit 2023-06-14 14:34:06 -07:00
cheezedoodle2 1beb86f483 Testing issue linking in title #3
testing issue linking in body #3
2023-06-14 14:31:13 -07:00
Sloetjes bdd9450062 Debug syntax fixed 2023-06-14 16:23:16 -04:00
Karenzz 5fcf89f85d Installed requests module for Slotjes to test 2023-06-14 15:06:02 -04:00
Karenzz 612244b76b Created /opt/pricer directory 2023-06-13 16:44:33 -04:00
cheezedoodle2 7c88a1501d Merged ansible playbook, re-ordered things 2023-06-12 17:03:08 -07:00
xuanyi.wang b1cb97d3f1 Update 'basic_checks_Sloetjes.yml' 2023-06-12 21:33:49 +02:00
xuanyi.wang 27ee1ce76c Update 'basic_checks_Sloetjes.yml' 2023-06-12 21:31:44 +02:00
xuanyi.wang 68367e1070 Update 'basic_checks_Sloetjes.yml' 2023-06-12 20:05:29 +02:00
xuanyi.wang 4457b19137 Update 'basic_checks_Sloetjes.yml' 2023-06-12 19:55:24 +02:00
cheezedoodle2 6719fef4e8 Notes on how to get systemd running to install chromium 2023-06-12 05:17:06 -07:00
Karenzz 9af1def1d0 Updated package required 2023-06-09 15:21:54 -04:00
Karenzz 82bd82a5ea Updated packages required 2023-06-09 15:20:09 -04:00
9 changed files with 194 additions and 62 deletions
+3
View File
@@ -0,0 +1,3 @@
bin/**
lib/**
share/**
+175 -15
View File
@@ -1,34 +1,74 @@
- name: Prepare wsl distribution to run snapd
hosts: commander
tasks:
# TODO the conditional should be given only once in a block
- name: Install Docker
become: true
apt:
name: docker.io
state: present
when: "ansible_os_family == 'Debian'"
- name: Start Docker service
become: true
service:
name: docker
state: started
when: "ansible_os_family == 'Debian'"
- name: Start Docker for Desktop
hosts: commander
gather_facts: false
tasks:
- name: Start Docker for Desktop on MacOS
command: open /Applications/Docker.app
when: ansible_os_family == "Darwin"
- name: Install requests module
pip:
name: requests
state: present
- name: Start the pricer container normally
docker_container:
name: loving_benz
image: dev
state: started
restart_policy: always
ports:
- "2222:22"
register: container
- name: Debug container Config.Hostname
debug:
var: container.Config.Hostname
- name: Basic system checks
hosts: all
become: yes
become_user: root
hosts: docker_container
tasks:
- name: Check to make sure the package manager is apt
fail:
msg: "Package manager is not apt"
when: "ansible_pkg_mgr != 'apt'"
- name: Install git
hosts: all
tasks:
- name: Install git
apt:
name: git
state: present
- name: Check out the pricer repository
hosts: all
tasks:
- name: Checkout pricer repository
- name: Create /opt/pricer directory
file:
path: /opt/pricer
state: directory
mode: '0755'
- name: Check out the pricer repository
git:
repo: https://gogs.gtsplab.com:5432/SVIG/pricer.git
dest: /opt/pricer
version: main
- name: Install Python requirements
hosts: all
tasks:
- name: "Install setuptools + distutils + pkg-resources + pip"
- name: Install Python requirements setuptools + distutils + pkg-resources + pip
apt:
name:
- python3-setuptools
@@ -41,3 +81,123 @@
ansible.builtin.pip:
requirements: /opt/pricer/requirements.txt
- name: Install Selenium
ansible.builtin.pip:
name: selenium
state: present
# Install snapd here
# Start the container in privileged mode with:
# docker run --privileged --cgroupns=host -d -v /sys/fs/cgroup:/sys/fs/cgroup:rw dev /lib/systemd/systemd
# systemctl start snapd
# systemctl start udev
# snap install chromium
# You can use ansible.community.docker to run the container, then do all the above stuff
# docker_container_exec might be useful
#
# Translate the docker run command into the docker_container ansible module with these args:
# -v | volumes:
# --cgroupns | cgroupns_mode:
# -d | detach: true
#
# 1) Start the container with systemd, so we can use snap to install packages
# 2) Install chromium using snap
# 3) Stop the container
# 4) Re-start the container without systemd, using the default RUN command "/usr/sbin/sshd -D"
# 5) Run the scraper
- name: Start pricer container with systemd
hosts: commander
tasks:
- name: Run pricer container
docker_container:
# TODO: make sure to use the container id from above so you don't start another container
name: loving_benz
image: dev
state: started
restart_policy: always
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: yes
ports:
- "2222:22"
- "9515:9515"
command: /lib/systemd/systemd
- name: Continue installing chromium using snap
hosts: docker_container
become: true
tasks:
- name: Install requests module
pip:
name: requests
state: present
- name: Install snapd package
apt:
name: snapd
state: present
- name: Start udev
systemd:
name: udev
state: started
- name: Start snapd
systemd:
name: snapd.service
# Verify the exact name of the systemd service for snapd using `systemctl list-unit-files | grep snapd` on the host
state: started
- name: Install chromium
snap:
name: chromium
state: present
- name: Install Chromium and Chromedriver
hosts: docker_container
become: true
tasks:
- name: Install chromium-chromedriver package
apt:
name: chromium-chromedriver
state: present
- name: Install chromium-browser package
apt:
name: chromium-browser
state: present
- name: Verify the chromium browser is running at the specified port
hosts: docker_container
become: true
tasks:
- name: install the net-tools
apt:
name: net-tools
state: present
- name: Get Chromium browser port
command: netstat -tlnp | grep chromium | awk '{split($4,a,":"); print a[length(a)]}'
register: chromium_port
- name: Display Chromium browser port
debug:
var: chromium_port.stdout
- name: Run latest version of scraper
hosts: docker_container
become: true
tasks:
- name: Set up Chrome options
set_fact:
chrome_options:
- "--headless"
- "--no-sandbox"
- "--disable-dev-shm-usage"
- name: Debug chrome_options variable
debug:
var: chrome_options
- name: Run scraper
ansible.builtin.script:
script: /opt/pricer/fp2_13.py
executable: /usr/bin/python3
environment:
PATH: "/usr/bin/chromedriver/:{{ ansible_env.PATH }}"
CHROME_OPTIONS: "{{ chrome_options | join(' ') }}"
-38
View File
@@ -1,38 +0,0 @@
- name: Basic system checks
hosts: all
tasks:
- name: Check to make sure the package manager is apt
fail:
msg: "Package manager is not apt"
when: "ansible_pkg_mgr != 'apt'"
- name: Clone pricer repository
hosts: target_hosts
become: yes
tasks:
- name: Check out pricer repository
git:
repo: https://github.com/your-username/pricer.git
dest: /path/to/pricer
- name: Install Python requirements
hosts: target_hosts
become: yes
tasks:
- name: Install Python requirements
pip:
requirements: /Users/sloetjeswong/pricer/requirements.txt
- name: Install Chromium and Selenium
hosts: target_hosts
become: yes
tasks:
- name: Install Chromium
apt:
name: chromium-browser
state: present
- name: Install Selenium
pip:
name: selenium
state: present
+3
View File
@@ -8,5 +8,8 @@ RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/s
RUN sed -i 's/#KbdInteractiveAuthentication yes/KbdInteractiveAuthentication no/' /etc/ssh/sshd_config
ADD authorized_keys /root/.ssh/authorized_keys
RUN chmod 600 /root/.ssh/authorized_keys
# Ansible
EXPOSE 22
# Chromedriver
EXPOSE 9515
CMD ["/usr/sbin/sshd", "-D"]
+1 -1
View File
@@ -1,3 +1,3 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCpXelnFwuVHcdbHjrvcChhxiBzXmAOPb43Yhb5W+ix93YS/TaWuDSLUxf1l1XAy45ESgMzI0GxMXakVoT5Ns0yrKgpk4ZJRlVGV03SJEwHL80JaQzjXXuo5fFE/CpaNJJHmtzobE1uzs8yz0qkd12iY4yCZvzelazarJNhy/jSFrXJZuVh2jvxkr4SpHQg9VBOJMaDH2cF9s6a45wtjXJz2sUsaLyRIhWGA78xpS6u9gxWX1IZXCcl6TMEktSv503QKQI8YitWOuGr4CkhBlrg9aMhQu6bxDzep0UQVfn2sIwj1m8+bO+mzYI6hHo2odeQtTVcoby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TvdcftORUuYK3c5hB3VPqCInPqDW8YrEomSanBUeZXQVdsxFxgEEelEDWKDKoHonHkQ== sloetjeswong@Sloetjess-Air
+4 -1
View File
@@ -1,3 +1,6 @@
#!/bin/bash
# Run the docker container
docker run -p 2222:22 -d dev
# This will get systemd up enough to run snapd
# See: https://docs.docker.com/desktop/release-notes/#bug-fixes-and-minor-changes
# docker run --privileged --cgroupns=host -d -v /sys/fs/cgroup:/sys/fs/cgroup:rw dev /lib/systemd/systemd
docker run -p 2222:22 -p 9515:9515 -d dev
+1 -1
View File
@@ -42,7 +42,7 @@ subscription = subscriber.create_subscription(
# Publish a message to the topic
# Read the data from the csv file
# file_path = "C:/Users/Karen/Desktop/zipcodes.csv"
file_path = "zipcodes.csv"
file_path = "karen-zipcodes.csv"
with open(file_path, "r") as csv_file:
reader = csv.reader(csv_file)
+5 -2
View File
@@ -1,5 +1,8 @@
oci:
dev:
hosts:
localhost:
docker_container:
ansible_host: localhost
ansible_user: root
ansible_port: 2222
commander:
ansible_connection: local
+2 -4
View File
@@ -1,5 +1,4 @@
google.cloud.pubsub
google.api_core.exceptions
plotly
pandas
numpy
@@ -7,9 +6,8 @@ h5py
selenium
sqlalchemy
flask
sys
ntplib
arrow
h5py
ansible
ansible-lint