commit d15e45068e182719f1235877cf9d568f51e8446e Author: xiaoxue Date: Mon May 25 00:26:26 2026 +0800 同步完整源码 - 2026-05-25 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..81448c0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +* +!gerapy +!poetry.lock +!pyproject.toml +!README.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..ff584aa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,36 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: Germey + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Traceback** +Copy traceback displayed in console to here. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Environment (please complete the following information):** + - OS: [e.g. Windows 10] + - Browser [e.g. Chrome 67] + - Python Version [e.g. 3.6.2] + - Gerapy Version [e.g. 0.8.6] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..443c01a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: build +on: + push: + branches: + - master + - dev + pull_request: + branches: + - master + +env: + POETRY_VERSION: "1.3.1" + +jobs: + test-on-linux: + runs-on: + - ubuntu-latest + strategy: + max-parallel: 3 + matrix: + python-version: [3.7, 3.8] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Poetry ${{ env.POETRY_VERSION }} with Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install poetry + # see https://github.com/marketplace/actions/setup-poetry + uses: Gr1N/setup-poetry@v7 + with: + poetry-version: ${{ env.POETRY_VERSION }} + - name: Install dependencies + run: poetry install --no-root + - name: Build wheel + run: poetry build --format wheel + - name: Install Gerapy + run: pip install dist/gerapy-*.whl + - name: Run Gerapy + env: + PATH: "/root/.local/bin:$PATH" + run: | + gerapy -v + gerapy init + cd gerapy + gerapy migrate + gerapy initadmin diff --git a/.github/workflows/build_docker_image_master.yml b/.github/workflows/build_docker_image_master.yml new file mode 100644 index 0000000..1129edb --- /dev/null +++ b/.github/workflows/build_docker_image_master.yml @@ -0,0 +1,31 @@ +name: build docker image master +on: + push: + branches: + - master + paths: + - .github/workflows/** + - gerapy/** +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v1 + - name: Docker Login + run: docker login -u germey -p ${{ secrets.DOCKERHUB_LOGIN_PASSWORD }} + - name: Setup Node.js + uses: actions/setup-node@v2.3.0 + with: + version: 14.x + - name: Build Frontend Source + run: | + cd gerapy/client + npm install -g yarn + yarn + yarn build + - name: Build the Docker Image + run: | + docker build -t germey/gerapy:master . + - name: Push the Docker Image + run: docker push germey/gerapy:master diff --git a/.github/workflows/build_docker_image_release.yml b/.github/workflows/build_docker_image_release.yml new file mode 100644 index 0000000..d732c7b --- /dev/null +++ b/.github/workflows/build_docker_image_release.yml @@ -0,0 +1,35 @@ +name: build docker image release +on: + push: + tags: + - 'v*.*.*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v1 + - name: Docker Login + run: docker login -u germey -p ${{ secrets.DOCKERHUB_LOGIN_PASSWORD }} + - name: Setup Node.js + uses: actions/setup-node@v2.3.0 + with: + version: 14.x + - name: Build Frontend Source + run: | + cd gerapy/client + npm install -g yarn + yarn + yarn build + - name: Build and Push the Docker Image + run: | + tag=${GITHUB_REF:11} + echo "Build Tag '$tag'" + docker build -t germey/gerapy:$tag . + docker push germey/gerapy:$tag + regex='^([0-9]+\.){0,2}(\*|[0-9]+)$' + if [[ $tag =~ $regex ]]; then + echo "Build Stable Version '$tag'" + docker tag germey/gerapy:$tag germey/gerapy:latest + docker push germey/gerapy:latest + fi diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..d3d0113 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '32 11 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/sync_docs.yml b/.github/workflows/sync_docs.yml new file mode 100644 index 0000000..058d72b --- /dev/null +++ b/.github/workflows/sync_docs.yml @@ -0,0 +1,37 @@ +name: sync docs +on: + push: + branches: + - release +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Set SSH Environment + env: + DOCS_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }} + run: | + mkdir -p ~/.ssh/ + echo "$DOCS_DEPLOY_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com > ~/.ssh/known_hosts + chmod 700 ~/.ssh && chmod 600 ~/.ssh/* + git config --global user.email "cqc@cuiqingcai.com" + git config --global user.name "Germey" + - name: Sync Docs of Gerapy + run: | + cd /tmp + git clone git@github.com:Gerapy/Docs.git docs + cd docs + git branch -D docs || true + git push origin --delete docs || true + git clone https://github.com/Gerapy/Gerapy.git gerapy + cd gerapy + git subtree split --prefix=docs --squash -b docs + git checkout docs + git push /tmp/docs docs:docs + cd /tmp/docs + git checkout docs + git checkout -b master || git checkout master || true + git reset --hard docs + git push origin master --force diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3e0167 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Created by .ignore support plugin (hsz.mobi) +/.idea +/.vscode +/.vagrant +*.pyc +/gerapy.egg-info +/dist +/build +npm-debug.log +/test +/tests +/gerapy/server/.idea/ +/logs/ +/gerapy/.idea +/gerapy/logs/ +gerapy/server/logs/ +db.sqlite3 +install.sh +*.pyc +.venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8a8b24f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,56 @@ +FROM python:3.10-slim AS build +ENV PATH="/root/.local/bin:$PATH" +WORKDIR /app +COPY . /app +# Install poetry +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends curl; \ + curl -sSL https://install.python-poetry.org | python3 -; \ + poetry --version +# Build gerapy +RUN set -eux; \ + poetry install; \ + poetry build --format wheel + + +FROM python:3.10-slim +# Install gerapy +ENV GERAPY_HOME_DIR ${GERAPY_HOME_DIR:-/home/gerapy} +ENV GERAPY_GROUP ${GERAPY_GROUP:-gerapy} +ENV GERAPY_GID ${GERAPY_GID:-10000} +ENV GERAPY_USER ${GERAPY_USER:-gerapy} +ENV GERAPY_UID ${GERAPY_UID:-10000} +ENV GERAPY_PORT ${GERAPY_PORT:-8000} +WORKDIR $GERAPY_HOME_DIR +COPY --from=build /app/dist/gerapy-*.whl /tmp/ +RUN \ + set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends tini gosu; \ + pip install /tmp/gerapy-*.whl; \ + rm -f /tmp/gerapy-*.whl; \ + mkdir -p $GERAPY_HOME_DIR; \ + addgroup --gid $GERAPY_GID $GERAPY_GROUP; \ + adduser --uid $GERAPY_UID --home $GERAPY_HOME_DIR --ingroup $GERAPY_GROUP $GERAPY_USER; \ + chown $GERAPY_USER:$GERAPY_GROUP $GERAPY_HOME_DIR; \ + pip cache purge; \ + apt autoclean; \ + rm -rf /var/lib/apt/lists/*; +# Build run script +RUN \ + set -eux; \ + runscript="/usr/local/bin/gerapy-runner"; \ + echo "#!/bin/sh -ex" > $runscript; \ + echo >> $runscript; \ + echo "find \"$GERAPY_HOME_DIR\" \! -user \"$GERAPY_USER\" -exec chown $GERAPY_USER:$GERAPY_GROUP '{}' +" >> $runscript; \ + cmd="gosu $GERAPY_USER:$GERAPY_GROUP gerapy"; \ + echo "$cmd init ." >> $runscript; \ + echo "$cmd migrate" >> $runscript; \ + echo "$cmd initadmin" >> $runscript; \ + echo "$cmd runserver 0.0.0.0:$GERAPY_PORT" >> $runscript; \ + chmod +x $runscript; +VOLUME $GERAPY_HOME_DIR +EXPOSE $GERAPY_PORT +ENTRYPOINT ["tini", "--"] +CMD ["gerapy-runner"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d051104 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017-2019, Germey + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e33ec48 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include *.txt +include *.rst +include *.tmpl + +include LICENSE \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..28f0232 --- /dev/null +++ b/README.md @@ -0,0 +1,113 @@ +# Gerapy + +![Build](https://github.com/Gerapy/Gerapy/workflows/build/badge.svg) +![Read the Docs](https://img.shields.io/readthedocs/gerapy) +![PyPI - Python Version](https://img.shields.io/badge/python-3.6%2B-blue) +[![GitHub stars](https://img.shields.io/github/stars/Gerapy/Gerapy)](https://github.com/Gerapy/Gerapy/stargazers) +![PyPI - Downloads](https://img.shields.io/pypi/dm/gerapy) +![Docker Pulls](https://img.shields.io/docker/pulls/germey/gerapy) +![PyPI - License](https://img.shields.io/pypi/l/gerapy) + +Distributed Crawler Management Framework Based on Scrapy, Scrapyd, Scrapyd-Client, Scrapyd-API, Django and Vue.js. + +## Documentation + +Documentation is available online at [https://docs.gerapy.com/](https://docs.gerapy.com/) and [https://github.com/Gerapy/Docs](https://github.com/Gerapy/Docs). + +## Support + +Gerapy is developed based on Python 3.x. Python 2.x may be supported later. + +## Usage + +Install Gerapy by pip: + +```bash +pip3 install gerapy +``` + +After the installation, you need to do these things below to run Gerapy server: + +If you have installed Gerapy successfully, you can use command `gerapy`. If not, check the installation. + +First use this command to initialize the workspace: + +```bash +gerapy init +``` + +Now you will get a folder named `gerapy`. Also you can specify the name of your workspace by this command: + +``` +gerapy init +``` + +Then `cd` to this folder, and run this command to initialize the Database: + +```bash +cd gerapy +gerapy migrate +``` + +Next you need to create a superuser by this command: + +``` +gerapy createsuperuser +``` + +Then you can runserver by this command: + +```bash +gerapy runserver +``` + +Then you can visit [http://localhost:8000](http://localhost:8000) to enjoy it. Also you can vist [http://localhost:8000/admin](http://localhost:8000/admin) to get the admin management backend. + +If you want to run Gerapy in public, just run like this: + +``` +gerapy runserver 0.0.0.0:8000 +``` + +Then it will run with public host and port 8000. + +In Gerapy, You can create a configurable project and then configure and generate code of Scrapy automatically. But this module is unstable, we're trying to refine it. + +Also you can drag your Scrapy Project to `projects` folder. Then refresh web, it will appear in the Project Index Page and comes to un-configurable, but you can edit this project through the web page. + +As for deployment, you can move to Deploy Page. Firstly you need to build your project and add client in the Client Index Page, then you can deploy the project just by clicking button. + +After the deployment, you can manage the job in Monitor Page. + +## Docker + +Just run this command: + +``` +docker-compose up +``` + +Then it will run at port 8000. You can use the temp admin account (username: admin, password: admin) to login. And please change the password later for safety. + +Command Usage: + +``` +docker run -d -v :/home/gerapy -p : germey/gerapy +``` + +Please specify your workspace to mount Gerapy workspace by `-v :/app/gerapy` and specify server port by `-p :`. + +If you run Gerapy by Docker, you can visit Gerapy website such as [http://localhost:8000](http://localhost:8000) and enjoy it, no need to do other initialzation things. + +## TodoList + +- [x] Add Visual Configuration of Spider with Previewing Website +- [x] Add Scrapyd Auth Management +- [x] Add Gerapy Auth Management +- [x] Add Timed Task Scheduler +- [ ] Add Visual Configuration of Scrapy +- [ ] Add Intelligent Analysis of Web Page + +## Communication + +If you have any questions or ideas, you can send [Issues](https://github.com/Gerapy/Gerapy/issues) or [Pull Requests](https://github.com/Gerapy/Gerapy/pulls), your suggestions are really import for us, thanks for your contirbution. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b0f2c8d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 0.9.8 | Fixed issue of remote executing, https://github.com/Gerapy/Gerapy/issues/219 | + +## Reporting a Vulnerability + +Please open an issue or send mail to `cqc@cuiqingcai.com`, thanks. diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..0a088db --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,34 @@ +This is a PlayBooks deployment of Python3.6.4 using Ansible + +#### Do the following: +- Change Yum source to Ali source +- Added EPEL source +- Firewalld open port 6800 +- Disable Chronyd, change to NTP (Ali NTP Server) +- Disable Selinux +- Install Python3 compilation dependent components, and compile and install Python3, the soft connection is: / usr / bin / python3 + +#### Instructions: +- Install Ansible([Install Docs](http://www.ansible.com.cn/docs/intro_installation.html)) +- Generate a management key +- Deploy host IP or domain name into host +- Run copy_ssh.sh(Default root user, manually enter the password (Ctrl + C and Ctrl + V)) +- All needed Python packages, written in list form install_pip_package (/Deploy_Python3/group_vars/all) +- If you want to change the Python installation path, change: Variable python_path(/Deploy_Python3/group_vars/all) + + +After preparation is completed。 + +Run the following command in the Deploy_Python3 directory: + + ansible-playbooks -i host site.yml + +Waiting to be completed + +Done + +#### Instructions for Vagrant: + +cd into project directory and run `vagrant up` then `cd Deploy_Python3` and run + + ansible-playbook site.yml diff --git a/deploy/ansible.cfg b/deploy/ansible.cfg new file mode 100644 index 0000000..edda238 --- /dev/null +++ b/deploy/ansible.cfg @@ -0,0 +1,15 @@ +[defaults] + +# some basic default values... + +inventory = ./hosts +remote_user = vagrant +roles_path = ./roles +timeout = 60 + +[ssh_connection] + +# ssh arguments to use +# Leaving off ControlPersist will result in poor performance, so use +# paramiko on older platforms rather than removing it, -C controls compression use +ssh_args = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=120s \ No newline at end of file diff --git a/deploy/copy_ssh.sh b/deploy/copy_ssh.sh new file mode 100644 index 0000000..60fc7ab --- /dev/null +++ b/deploy/copy_ssh.sh @@ -0,0 +1,5 @@ +cat ./host | while read line +do + echo "正在处理:${line}" + ssh-copy-id -i ~/.ssh/id_rsa.pub -o StrictHostKeyChecking=no root@${line} +done diff --git a/deploy/group_vars/all b/deploy/group_vars/all new file mode 100644 index 0000000..75dd5e4 --- /dev/null +++ b/deploy/group_vars/all @@ -0,0 +1,5 @@ +# Python Install Path + +python_path : /usr/local/bin/gerapy + +install_pip_package : [selenium, scrapyd] \ No newline at end of file diff --git a/deploy/hosts b/deploy/hosts new file mode 100644 index 0000000..e920ee3 --- /dev/null +++ b/deploy/hosts @@ -0,0 +1,9 @@ +# for testing with vagrant +[gerapy1] +192.168.33.10 + +[gerapy1:vars] +ansible_user=vagrant +ansible_ssh_port=22 +ansible_ssh_private_key_file=./.vagrant/machines/default/virtualbox/private_key +ansible_python_interpreter=/usr/bin/python \ No newline at end of file diff --git a/deploy/roles/common/files/CentOS-Base.repo b/deploy/roles/common/files/CentOS-Base.repo new file mode 100644 index 0000000..dbfe274 --- /dev/null +++ b/deploy/roles/common/files/CentOS-Base.repo @@ -0,0 +1,62 @@ +# CentOS-Base.repo +# +# The mirror system uses the connecting IP address of the client and the +# update status of each mirror to pick mirrors that are updated to and +# geographically close to the client. You should use this for CentOS updates +# unless you are manually picking other mirrors. +# +# If the mirrorlist= does not work for you, as a fall back you can try the +# remarked out baseurl= line instead. +# +# + +[base] +name=CentOS-$releasever - Base - mirrors.aliyun.com +failovermethod=priority +baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ + http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os +gpgcheck=1 +gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 + +#released updates +[updates] +name=CentOS-$releasever - Updates - mirrors.aliyun.com +failovermethod=priority +baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ + http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates +gpgcheck=1 +gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 + +#additional packages that may be useful +[extras] +name=CentOS-$releasever - Extras - mirrors.aliyun.com +failovermethod=priority +baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ + http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras +gpgcheck=1 +gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 + +#additional packages that extend functionality of existing packages +[centosplus] +name=CentOS-$releasever - Plus - mirrors.aliyun.com +failovermethod=priority +baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ + http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus +gpgcheck=1 +enabled=0 +gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 + +#contrib - packages by Centos Users +[contrib] +name=CentOS-$releasever - Contrib - mirrors.aliyun.com +failovermethod=priority +baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ + http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ +#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib +gpgcheck=1 +enabled=0 +gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 \ No newline at end of file diff --git a/deploy/roles/common/files/RPM-GPG-KEY-EPEL-7 b/deploy/roles/common/files/RPM-GPG-KEY-EPEL-7 new file mode 100644 index 0000000..a1d6f25 --- /dev/null +++ b/deploy/roles/common/files/RPM-GPG-KEY-EPEL-7 @@ -0,0 +1,29 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (GNU/Linux) + +mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB +OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm +jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP +vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM +jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4lsZ+Y2Er9Yu5 +S/8x0ly+tmmIokaE0wwbdUu740YTZjCesroYWiRg5zuQ2xfKxJoV5E+Eh+tYwGDJ +n6HfWhRgnudRRwvuJ45ztYVtKulKw8QQpd2STWrcQQDJaRWmnMooX/PATTjCBExB +9dkz38Druvk7IkHMtsIqlkAOQMdsX1d3Tov6BE2XDjIG0zFxLduJGbVwc/6rIc95 +T055j36Ez0HrjxdpTGOOHxRqMK5m9flFbaxxtDnS7w77WqzW7HjFrD0VeTx2vnjj +GqchHEQpfDpFOzb8LTFhgYidyRNUflQY35WLOzLNV+pV3eQ3Jg11UFwelSNLqfQf +uFRGc+zcwkNjHh5yPvm9odR1BIfqJ6sKGPGbtPNXo7ERMRypWyRz0zi0twARAQAB +tChGZWRvcmEgRVBFTCAoNykgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iQI4BBMB +AgAiBQJSrmiEAhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBqL66iNSxk +5cfGD/4spqpsTjtDM7qpytKLHKruZtvuWiqt5RfvT9ww9GUUFMZ4ZZGX4nUXg49q +ixDLayWR8ddG/s5kyOi3C0uX/6inzaYyRg+Bh70brqKUK14F1BrrPi29eaKfG+Gu +MFtXdBG2a7OtPmw3yuKmq9Epv6B0mP6E5KSdvSRSqJWtGcA6wRS/wDzXJENHp5re +9Ism3CYydpy0GLRA5wo4fPB5uLdUhLEUDvh2KK//fMjja3o0L+SNz8N0aDZyn5Ax +CU9RB3EHcTecFgoy5umRj99BZrebR1NO+4gBrivIfdvD4fJNfNBHXwhSH9ACGCNv +HnXVjHQF9iHWApKkRIeh8Fr2n5dtfJEF7SEX8GbX7FbsWo29kXMrVgNqHNyDnfAB +VoPubgQdtJZJkVZAkaHrMu8AytwT62Q4eNqmJI1aWbZQNI5jWYqc6RKuCK6/F99q +thFT9gJO17+yRuL6Uv2/vgzVR1RGdwVLKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc +ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4 +vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt +RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw== +=hdPa +-----END PGP PUBLIC KEY BLOCK----- \ No newline at end of file diff --git a/deploy/roles/common/files/epel.repo b/deploy/roles/common/files/epel.repo new file mode 100644 index 0000000..428e102 --- /dev/null +++ b/deploy/roles/common/files/epel.repo @@ -0,0 +1,29 @@ +[epel] +name=Extra Packages for Enterprise Linux 7 - $basearch +baseurl=http://mirrors.aliyun.com/epel/7/$basearch + http://mirrors.aliyuncs.com/epel/7/$basearch +#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 + +[epel-debuginfo] +name=Extra Packages for Enterprise Linux 7 - $basearch - Debug +baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug + http://mirrors.aliyuncs.com/epel/7/$basearch/debug +#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=0 + +[epel-source] +name=Extra Packages for Enterprise Linux 7 - $basearch - Source +baseurl=http://mirrors.aliyun.com/epel/7/SRPMS + http://mirrors.aliyuncs.com/epel/7/SRPMS +#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=0 diff --git a/deploy/roles/common/files/ntp.conf b/deploy/roles/common/files/ntp.conf new file mode 100644 index 0000000..42bd82e --- /dev/null +++ b/deploy/roles/common/files/ntp.conf @@ -0,0 +1,47 @@ +# Permit all access over the loopback interface. This could +# be tightened as well, but to do so would effect some of +# the administrative functions. +## 允许下面的地址进入此NTP服务器 +restrict 127.0.0.1 +restrict ::1 +restrict time1.aliyun.com prefer +restrict time2.aliyun.com +restrict time3.aliyun.com +restrict time4.aliyun.com +restrict time5.aliyun.com +restrict time6.aliyun.com +restrict time7.aliyun.com + + +# Hosts on local network are less restricted. +## 允许下面的网段访问 此NTP服务器 +# restrict 10.10.1.0 mask 255.255.252.0 nomodify + + + +# Use public servers from the pool.ntp.org project. +# Please consider joining the pool (http://www.pool.ntp.org/join.html). +#server 0.centos.pool.ntp.org iburst +#server 1.centos.pool.ntp.org iburst +#server 2.centos.pool.ntp.org iburst +#server 3.centos.pool.ntp.org iburst +## 下面是阿里云的NTP服务器 prefre为首选 +server time1.aliyun.com prefer +server time2.aliyun.com +server time3.aliyun.com +server time4.aliyun.com +server time5.aliyun.com +server time6.aliyun.com +server time7.aliyun.com +# server 10.10.1.251 + +# 如果上面的NTP失效则以本机作为NTP服务器 +server 127.0.0.1 # local clock +fudge 127.0.0.1 stratum 10 + +#broadcast 192.168.1.255 autokey # broadcast server +#broadcastclient # broadcast client +#broadcast 224.0.1.1 autokey # multicast server +#multicastclient 224.0.1.1 # multicast client +#manycastserver 239.255.254.254 # manycast server +#manycastclient 239.255.254.254 autokey # manycast client \ No newline at end of file diff --git a/deploy/roles/common/tasks/main.yml b/deploy/roles/common/tasks/main.yml new file mode 100644 index 0000000..13aa8ee --- /dev/null +++ b/deploy/roles/common/tasks/main.yml @@ -0,0 +1,53 @@ +--- +- name: Copy the CentOS repository definition + copy: src=CentOS-Base.repo dest=/etc/yum.repos.d/CentOS-Base.repo force=yes + +- name: Create the repository for EPEL + copy: src=epel.repo dest=/etc/yum.repos.d/epel.repo + +- name: Create the GPG key for EPEL + copy: src=RPM-GPG-KEY-EPEL-7 dest=/etc/pki/rpm-gpg + +- name: Create Scrapyd 6800 Firewalld Rule + firewalld: port=6800/tcp permanent=true state=enabled + +- name: Create Scrapyd 6800 Firewalld Rule + firewalld: port=6800/udp permanent=true state=enabled + +#- name: Chronyd service stop +# service: name=chronyd state=stopped enabled=no + +- name: Install Ansible Base package + yum: name={{item}} state=installed + with_items: + - libselinux-python + - libsemanage-python + - ntp + +- name: Install Python3 Base package + yum: name={{item}} state=installed + with_items: + - xz + - gcc + - zlib + - zlib-devel + - openssl-devel + - bzip2-devel + - expat-devel + - gdbm-devel + - readline-devel + - sqlite-devel + - bzip2 + +- name: Configure SELinux to disable + selinux: state=disabled + +#- name: Change TimeZone +# timezone: +# name: Asia/Shanghai +# +#- name: Copy NTP conf +# copy: src=ntp.conf dest=/etc/ntp.conf force=yes +# +#- name: NTP Start +# service: name=ntpd state=started enabled=yes \ No newline at end of file diff --git a/deploy/roles/openresty/files/nginx.conf b/deploy/roles/openresty/files/nginx.conf new file mode 100644 index 0000000..e6af2fe --- /dev/null +++ b/deploy/roles/openresty/files/nginx.conf @@ -0,0 +1,67 @@ +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + upstream tornadoes { + server 127.0.0.1:6801; + } + + server { + listen 6800; + server_name localhost; + + location / { + proxy_pass_header Server; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_pass http://tornadoes; + auth_basic 'scrapyd'; + auth_basic_user_file /usr/local/openresty/nginx/conf/scrapyd.passwd; + } + } + + server { + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm index.php; + } + + } + +} diff --git a/deploy/roles/openresty/files/openresty.repo b/deploy/roles/openresty/files/openresty.repo new file mode 100644 index 0000000..16cab19 --- /dev/null +++ b/deploy/roles/openresty/files/openresty.repo @@ -0,0 +1,7 @@ +[openresty] +name=Official OpenResty Open Source Repository for CentOS +baseurl=https://openresty.org/package/centos/$releasever/$basearch +skip_if_unavailable=False +gpgkey=https://openresty.org/package/pubkey.gpg +enabled=1 +enabled_metadata=1 \ No newline at end of file diff --git a/deploy/roles/openresty/files/scrapyd.passwd b/deploy/roles/openresty/files/scrapyd.passwd new file mode 100644 index 0000000..c6b22f3 --- /dev/null +++ b/deploy/roles/openresty/files/scrapyd.passwd @@ -0,0 +1 @@ +scrapyd:$apr1$tImD91VL$uA4R1MEtgx1Q0hwcVunAE. \ No newline at end of file diff --git a/deploy/roles/openresty/tasks/main.yml b/deploy/roles/openresty/tasks/main.yml new file mode 100644 index 0000000..e86dacc --- /dev/null +++ b/deploy/roles/openresty/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- name: Copy the CentOS repository definition + copy: src=openresty.repo dest=/etc/yum.repos.d/openresty.repo force=yes + +- name: Install openresty + yum: name=openresty state=installed disable_gpg_check=no + +- name: Copy OpenResty Conf + copy: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf force=yes + +- name: Copy Auth + copy: src=scrapyd.passwd dest=/usr/local/openresty/nginx/conf/scrapyd.passwd force=yes + +- name: openresty Start + service: name=openresty state=started enabled=yes + + diff --git a/deploy/roles/python3/files/Python-3.6.4.tar.xz b/deploy/roles/python3/files/Python-3.6.4.tar.xz new file mode 100644 index 0000000..fee9753 Binary files /dev/null and b/deploy/roles/python3/files/Python-3.6.4.tar.xz differ