# HG changeset patch # User Luke Hoersten # Date 1534469156 18000 # Node ID 48a3a65119d5bfac98b63f22540008bf479724b5 Initial commit. diff -r 000000000000 -r 48a3a65119d5 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,9 @@ +syntax: regexp +\.DS_Store$ +\.vagrant/ +\.tfstate\.backup$ +\.tfstate\.blank$ +\.terraform/ +TAGS$ +tags$ +^group_vars/ diff -r 000000000000 -r 48a3a65119d5 Vagrantfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Vagrantfile Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,24 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/bionic64" + + config.vm.network "forwarded_port", guest: 4000, host: 4000 + # config.vm.synced_folder "../data", "/vagrant_data" + + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + + config.vm.provision "ansible" do |ansible| + ansible.limit = "all,localhost" + # ansible.verbose = "vvv" + ansible.playbook = "vagrant.yaml" + ansible.compatibility_mode = "2.0" + end +end diff -r 000000000000 -r 48a3a65119d5 ansible.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ansible.cfg Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,17 @@ +[defaults] +remote_tmp = ~/.ansible/tmp + +retry_files_enabled = false +roles_path = ./roles +become_flags = -H -S -n -E +squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper +merge_multiple_cli_flags = true + +# SSH +timeout = 10 +executable = /bin/bash +host_key_checking = False +#remote_port = 22 + +[ssh_connection] +pipelining = true diff -r 000000000000 -r 48a3a65119d5 roles/pleroma/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/pleroma/defaults/main.yaml Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,5 @@ +--- + +pleroma_user: "pleroma" +pleroma_instance_name: "{{pleroma_host}}" +pleroma_admin_email: "admin@{{pleroma_host}}" diff -r 000000000000 -r 48a3a65119d5 roles/pleroma/tasks/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/pleroma/tasks/main.yaml Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,86 @@ +--- + +- name: add erland solutions key + become: yes + apt_key: "url=http://packages.erlang-solutions.com/debian/erlang_solutions.asc" + +- name: install erland solutions repo + become: yes + apt_repository: repo="deb http://binaries.erlang-solutions.com/debian bionic contrib" + +- name: update apt package cache + become: yes + apt: upgrade="dist" update_cache="yes" cache_valid_time="3600" + +- name: install extra apt packages + become: yes + apt: name="{{item}}" + with_items: + - "postgresql" + - "esl-erlang" + - "elixir" + - "build-essential" + - "git" + +- name: add users + become: yes + user: name="{{pleroma_user}}" shell="/bin/bash" + +- name: checkout plemora + become: yes + become_user: "{{pleroma_user}}" + git: + repo: "https://git.pleroma.social/pleroma/pleroma.git" + dest: "~{{pleroma_user}}/pleroma" + force: yes + +- name: update elixir dep + become: yes + become_user: "{{pleroma_user}}" + lineinfile: + path: "~{{pleroma_user}}/pleroma/mix.exs" + regexp: 'elixir: "~> 1.4",$' + line: 'elixir: "~> 1.7",' + +- name: install pleroma config files + template: + src: "{{item}}.j2" + dest: "~{{pleroma_user}}/pleroma/config/{{item}}" + owner: "{{pleroma_user}}" + group: "{{pleroma_user}}" + mode: "0775" + become: yes + become_user: "{{pleroma_user}}" + with_items: + - "setup_db.psql" + - "dev.secret.exs" + +- name: install pleroma psql + become: yes + become_user: "postgres" + command: "psql -f ~{{pleroma_user}}/pleroma/config/setup_db.psql" + +- name: migrate db + become: yes + become_user: "{{pleroma_user}}" + command: "{{item}}" + args: + chdir: "~{{pleroma_user}}/pleroma/" + with_items: + - "mix local.hex --force" + - "mix local.rebar --force" + - "mix deps.get" + - "mix ecto.migrate" + +- name: install pleroma systemd service + template: + src: "pleroma.service.j2" + dest: "/lib/systemd/system/pleroma.service" + owner: "{{pleroma_user}}" + group: "{{pleroma_user}}" + mode: "0770" + become: yes + +- name: enable pleroma systemd service + systemd: name="pleroma" enabled="yes" state="started" + become: yes diff -r 000000000000 -r 48a3a65119d5 roles/pleroma/templates/dev.secret.exs.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/pleroma/templates/dev.secret.exs.j2 Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,26 @@ +use Mix.Config + +config :pleroma, Pleroma.Web.Endpoint, + url: [host: "{{pleroma_host}}", scheme: "https", port: 443], + secret_key_base: "{{pleroma_secret_key}}" + +config :pleroma, :instance, + name: "{{pleroma_instance_name}}", + email: "{{pleroma_admin_email}}", + limit: 5000, + registrations_open: true, + dedupe_media: false + +config :pleroma, :media_proxy, + enabled: false, + redirect_on_failure: true + #base_url: "https://cache.pleroma.social" + +# Configure your database +config :pleroma, Pleroma.Repo, + adapter: Ecto.Adapters.Postgres, + username: "{{pleroma_user}}", + password: "{{pleroma_db_passwd}}", + database: "{{pleroma_user}}", + hostname: "localhost", + pool_size: 10 diff -r 000000000000 -r 48a3a65119d5 roles/pleroma/templates/pleroma.service.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/pleroma/templates/pleroma.service.j2 Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,15 @@ +[Unit] +Description=Pleroma social network +After=network.target postgresql.service + +[Service] +User={{pleroma_user}} +WorkingDirectory=/home/{{pleroma_user}}/pleroma +Environment="HOME=/home/{{pleroma_user}}" +ExecStart=/usr/local/bin/mix phx.server +ExecReload=/bin/kill $MAINPID +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff -r 000000000000 -r 48a3a65119d5 roles/pleroma/templates/setup_db.psql.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roles/pleroma/templates/setup_db.psql.j2 Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,9 @@ +CREATE USER {{pleroma_user}} WITH ENCRYPTED PASSWORD '{{pleroma_db_passwd}}' CREATEDB; +-- in case someone runs this second time accidentally +ALTER USER {{pleroma_user}} WITH ENCRYPTED PASSWORD '{{pleroma_db_passwd}}' CREATEDB; +CREATE DATABASE {{pleroma_user}}; +ALTER DATABASE {{pleroma_user}} OWNER TO {{pleroma_user}}; +\c {{pleroma_user}}; +--Extensions made by ecto.migrate that need superuser access +CREATE EXTENSION IF NOT EXISTS citext; +CREATE EXTENSION IF NOT EXISTS pg_trgm; diff -r 000000000000 -r 48a3a65119d5 vagrant.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vagrant.yaml Thu Aug 16 20:25:56 2018 -0500 @@ -0,0 +1,13 @@ +--- + +- name: setup python2 + hosts: all + gather_facts: no + tasks: + - name: install python2 + become: yes + raw: "apt-get install python -y" + +- hosts: all + roles: + - pleroma