123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- ---
- - name: Install Ruby
- become: true
- apt:
- pkg:
- - ruby
- - ruby-dev
- - postgresql
- - libpq-dev
- - python3-psycopg2
- - ruby-bundler
- - name: Create user
- become: true
- user:
- name: bgplookup
- - name: Download BgpLookup
- become: true
- become_user: bgplookup
- git:
- repo: https://codeberg.org/mark22k/BgpLookup.git
- dest: /home/bgplookup/BgpLookup/
- clone: true
- force: true
- - name: Copy systemd unit
- become: true
- copy:
- src: files/systemd.unit
- dest: "/etc/systemd/system/bgplookup.service"
- mode: 0664
- - name: Copy configuration file
- become: true
- template:
- src: templates/config.json.j2
- dest: "/home/bgplookup/BgpLookup/config.json"
- mode: 0664
- owner: bgplookup
- group: bgplookup
- - name: Remove lockfile
- become: true
- file:
- path: /home/bgplookup/BgpLookup/Gemfile.lock
- state: absent
- - name: Select puma as server
- become: true
- lineinfile:
- path: /home/bgplookup/BgpLookup/Gemfile
- search_string: "gem 'falcon'"
- line: "gem 'puma'"
- - name: Disable bundler require
- become: true
- lineinfile:
- path: /home/bgplookup/BgpLookup/config.ru
- search_string: "require 'bundler'"
- state: absent
- - name: Disable bundler require
- become: true
- lineinfile:
- path: /home/bgplookup/BgpLookup/config.ru
- search_string: "Bundler.require"
- state: absent
- - name: Install gems
- become: true
- become_user: bgplookup
- shell: GEM_HOME="$(ruby -e 'puts Gem.user_dir')" PATH="$GEM_HOME/bin:$PATH" bundle install
- args:
- chdir: /home/bgplookup/BgpLookup
- - name: Install cronjob
- become: true
- copy:
- src: files/cronjob.sh
- dest: /home/bgplookup/cronjob.sh
- mode: 0755
- owner: bgplookup
- group: bgplookup
- - name: Enable cronjob
- become: true
- become_user: bgplookup
- cron:
- name: Build relations
- minute: "*/30"
- job: /home/bgplookup/cronjob.sh
- - name: Install gems
- become: true
- become_user: bgplookup
- shell: GEM_HOME="$(ruby -e 'puts Gem.user_dir')" PATH="$GEM_HOME/bin:$PATH" bundle install
- args:
- chdir: /home/bgplookup/BgpLookup
- - name: Enable access to bird registry
- become: true
- file:
- path: /var/lib/bird/
- mode: go+x
- - name: Enable access to dn42 registry
- become: true
- file:
- path: /var/lib/bird/registry/
- mode: go+rx
- - name: Enable access to dn42 registry
- become: true
- file:
- path: /var/lib/bird/registry/
- mode: go+r
- recurse: true
- - name: Create PostgreSQL user
- become: true
- become_user: postgres
- community.postgresql.postgresql_user:
- name: bgplookup
- password: "{{ bgplookup.db.password }}"
- - name: Create PostgreSQL database
- become: true
- become_user: postgres
- community.postgresql.postgresql_db:
- name: bgplookup
- owner: bgplookup
- - name: Running Cronjon
- become: true
- become_user: bgplookup
- command: /home/bgplookup/cronjob.sh
- args:
- chdir: /home/bgplookup/BgpLookup
- - name: Enable systemd unit
- become: true
- systemd:
- daemon_reload: true
- name: bgplookup.service
- masked: false
- enabled: true
- state: restarted
- - name: Enable PostgreSQL
- become: true
- systemd:
- name: postgresql.service
- masked: false
- enabled: true
- state: restarted
|