diff --git a/README.md b/README.md index 2d52217..c1201b5 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ To run this ansible playbook, you need to: ## Install -Clone this repo: +Clone this repo: ``` git clone https://github.com/LemmyNet/lemmy-ansible.git cd lemmy-ansible ``` -Make a directory to hold your config: +Make a directory to hold your config: `mkdir -p inventory/host_vars/` @@ -38,15 +38,21 @@ Copy the sample inventory hosts file: Edit the inventory hosts file (inventory/hosts) to your liking. -Run the playbook: +Copy the sample postgresql.conf + +`cp examples/customPostgresql.conf inventory/customPostgresql.conf` + +You can use [the PGTune tool](https://pgtune.leopard.in.ua) to tune your postgres to meet your server memory and CPU. + +Run the playbook: `ansible-playbook -i inventory/hosts lemmy.yml` -*Note*: if you are not the root user or don't have password-less sudo, use this command: +_Note_: if you are not the root user or don't have password-less sudo, use this command: `ansible-playbook -i inventory/hosts lemmy.yml --become --ask-become-pass` -*Note*: if you haven't set up ssh keys, and ssh using a password, use the command: +_Note_: if you haven't set up ssh keys, and ssh using a password, use the command: `ansible-playbook -i inventory/hosts lemmy.yml --become --ask-pass --ask-become-pass` @@ -59,7 +65,7 @@ If the command above fails, you may need to comment out this line In the ansible ## Upgrading - Run `git pull` -- Check out the [Lemmy Releases Changelog](https://github.com/LemmyNet/lemmy/blob/main/RELEASES.md) to see if there are any config changes with the releases since your last. +- Check out the [Lemmy Releases Changelog](https://github.com/LemmyNet/lemmy/blob/main/RELEASES.md) to see if there are any config changes with the releases since your last. - Run `ansible-playbook -i inventory/hosts lemmy.yml --become` ## Migrating your existing install to use this deploy diff --git a/VERSION b/VERSION index 427cda0..c5523bd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.16.7 +0.17.0 diff --git a/examples/config.hjson b/examples/config.hjson index 6b4d76b..ae875c2 100644 --- a/examples/config.hjson +++ b/examples/config.hjson @@ -7,9 +7,9 @@ password: "{{ postgres_password }}" } hostname: "{{ domain }}" - pictrs_url: "http://pictrs:8080" - federation: { - enabled: true + pictrs: { + url: "http://pictrs:8080/" + api_key: "{{ postgres_password }}" } email: { smtp_server: "postfix:25" diff --git a/examples/customPostgresql.conf b/examples/customPostgresql.conf new file mode 100644 index 0000000..a484e77 --- /dev/null +++ b/examples/customPostgresql.conf @@ -0,0 +1,23 @@ +# DB Version: 15 +# OS Type: linux +# DB Type: web +# Total Memory (RAM): 8 GB +# CPUs num: 4 +# Data Storage: ssd + +max_connections = 200 +shared_buffers = 2GB +effective_cache_size = 6GB +maintenance_work_mem = 512MB +checkpoint_completion_target = 0.9 +wal_buffers = 16MB +default_statistics_target = 100 +random_page_cost = 1.1 +effective_io_concurrency = 200 +work_mem = 5242kB +min_wal_size = 1GB +max_wal_size = 4GB +max_worker_processes = 4 +max_parallel_workers_per_gather = 2 +max_parallel_workers = 4 +max_parallel_maintenance_workers = 2 diff --git a/lemmy.yml b/lemmy.yml index 9b17584..5fa5b74 100644 --- a/lemmy.yml +++ b/lemmy.yml @@ -21,15 +21,54 @@ - setup: # gather facts tasks: + - name: Install aptitude + apt: + name: aptitude + state: latest + update_cache: true + - name: install dependencies apt: - update_cache: yes + state: latest + update_cache: true pkg: - 'nginx' - - 'docker-compose' - - 'docker.io' - 'certbot' - 'python3-certbot-nginx' + - 'apt-transport-https' + - 'ca-certificates' + - 'curl' + - 'software-properties-common' + - 'python3-pip' + - 'virtualenv' + - 'python3-setuptools' + + - name: Add Docker GPG apt Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + + - name: Add Docker Repository + apt_repository: + repo: deb https://download.docker.com/linux/ubuntu focal stable + state: present + + - name: Update apt and install docker-ce + apt: + name: docker-ce + state: latest + update_cache: true + + - name: Install Docker Module for Python + pip: + name: docker + + - name: Install or upgrade docker-compose + get_url: + url : "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64" + dest: /usr/local/bin/docker-compose + mode: 'a+x' + force: yes - name: copy docker config copy: src='../files/docker-daemon.json' dest='/etc/docker/daemon.json' mode='0644' @@ -99,6 +138,15 @@ mode: '0600' owner: '1000' group: '1000' + + - name: add the customPostgresql.conf + template: + src: 'inventory/host_vars/{{domain}}/customPostgresql.conf' + dest: '{{lemmy_base_dir}}/{{domain}}/customPostgresql.conf' + mode: '0600' + owner: '1000' + group: '1000' + vars: postgres_password: "{{ lookup('password', 'inventory/host_vars/{{domain}}/passwords/postgres chars=ascii_letters,digits') }}" diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml index 0345a80..358056d 100644 --- a/templates/docker-compose.yml +++ b/templates/docker-compose.yml @@ -20,22 +20,23 @@ services: - "127.0.0.1:{{ lemmy_ui_port }}:1234" restart: always environment: - - LEMMY_INTERNAL_HOST=lemmy:8536 - - LEMMY_EXTERNAL_HOST={{ domain }} - - LEMMY_HTTPS=true + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8536 + - LEMMY_UI_LEMMY_EXTERNAL_HOST={{ domain }} + - LEMMY_UI_HTTPS=true volumes: - ./volumes/lemmy-ui/extra_themes:/app/extra_themes depends_on: - lemmy postgres: - image: postgres:12-alpine + image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD={{ postgres_password }} - POSTGRES_DB=lemmy volumes: - ./volumes/postgres:/var/lib/postgresql/data + - ./customPostgresql.conf:/etc/postgresql.conf restart: always pictrs: