154 lines
3.9 KiB
YAML

---
- name: Clone Agent Repository
become: yes
become_user: frappe
git:
repo: '{{ agent_repository_url }}'
dest: /home/jingrow/agent/repo
remote: upstream
version: '{% if agent_branch is defined and agent_branch is truthy %} {{ agent_branch }} {% else %} master {% endif %}'
update: yes
- name: Install Agent
become: yes
become_user: frappe
pip:
name: file:///home/jingrow/agent/repo
virtualenv: /home/jingrow/agent/env
virtualenv_python: python3
editable: yes
- name: Generate Agent Configuration File
become: yes
become_user: frappe
command: '/home/jingrow/agent/env/bin/agent setup config --name {{ server }} --workers {{ workers }} {% if proxy_ip is defined and proxy_ip is truthy %}--proxy-ip {{ proxy_ip }}{% endif %} {% if agent_sentry_dsn is defined and agent_sentry_dsn is truthy %}--sentry-dsn {{ agent_sentry_dsn }}{% endif %}'
args:
chdir: /home/jingrow/agent
- name: Setup Agent SQLite Database
become: yes
become_user: frappe
command: /home/jingrow/agent/env/bin/agent setup database
args:
chdir: /home/jingrow/agent
- name: Setup Agent Usage Tracker
become: yes
become_user: frappe
command: /home/jingrow/agent/env/bin/agent setup usage
args:
chdir: /home/jingrow/agent
- name: Setup Agent Site Analytics Tracker
become: yes
become_user: frappe
command: /home/jingrow/agent/env/bin/agent setup site-analytics
args:
chdir: /home/jingrow/agent
- name: Create Agent NGINX Configuration Directory
become: yes
become_user: frappe
file:
dest: /home/jingrow/agent/nginx
state: directory
- name: Setup Agent Authentication
become: yes
become_user: frappe
command: '/home/jingrow/agent/env/bin/agent setup authentication --password {{ agent_password }}'
args:
chdir: /home/jingrow/agent
- name: Symlink Agent Supervisor Configuration
file:
src: /home/jingrow/agent/supervisor.conf
dest: /etc/supervisor/conf.d/agent.conf
state: link
force: yes
follow: no
- name: Create Logs Directory for Supervisor
become: yes
become_user: frappe
file:
dest: /home/jingrow/agent/logs
state: directory
- name: Setup Agent Supervisor
become: yes
become_user: frappe
command: /home/jingrow/agent/env/bin/agent setup supervisor
args:
chdir: /home/jingrow/agent
- name: Create NGINX Root Configuration File
become: yes
become_user: frappe
file:
path: /home/jingrow/agent/nginx/nginx.conf
state: touch
- name: Symlink NGINX Root Configuration File
file:
src: /home/jingrow/agent/nginx/nginx.conf
dest: /etc/nginx/nginx.conf
state: link
force: yes
follow: no
- name: Create Agent NGINX Configuration File
become: yes
become_user: frappe
file:
path: /home/jingrow/agent/nginx.conf
state: touch
- name: Symlink Agent NGINX Configuration File
file:
src: /home/jingrow/agent/nginx.conf
dest: /etc/nginx/conf.d/agent.conf
state: link
force: yes
follow: no
- name: Create Agent TLS Directory
become: yes
become_user: frappe
file:
dest: /home/jingrow/agent/tls
state: directory
- name: Setup Agent TLS (Private Key)
become: yes
become_user: frappe
copy:
content: '{{ certificate_private_key }}'
dest: /home/jingrow/agent/tls/privkey.pem
- name: Setup Agent TLS (Full Chain)
become: yes
become_user: frappe
copy:
content: '{{ certificate_full_chain }}'
dest: /home/jingrow/agent/tls/fullchain.pem
- name: Setup Agent TLS (Intermediate Chain)
become: yes
become_user: frappe
copy:
content: '{{ certificate_intermediate_chain }}'
dest: /home/jingrow/agent/tls/chain.pem
- name: Setup Agent NGINX
become: yes
become_user: frappe
command: /home/jingrow/agent/env/bin/agent setup nginx
args:
chdir: /home/jingrow/agent
- name: Setup Monitoring Authentication
become: yes
become_user: frappe
command: 'htpasswd -Bbc /home/jingrow/agent/nginx/monitoring.htpasswd frappe {{ monitoring_password }}'