Repository: LemmyNet/lemmy-ansible
Branch: main
Commit: 96af7fae43d9
Files: 23
Total size: 89.5 KB
Directory structure:
gitextract_z5p8fxs3/
├── .github/
│ └── CODEOWNERS
├── .gitignore
├── .woodpecker.yml
├── LICENSE
├── README.md
├── UPGRADING.md
├── VERSION
├── ansible.cfg
├── examples/
│ ├── config.hjson
│ ├── customPostgresql.conf
│ ├── hosts
│ └── vars.yml
├── files/
│ ├── docker-daemon.json
│ └── proxy_params
├── lemmy-almalinux.yml
├── lemmy.yml
├── renovate.json
├── requirements.yml
├── templates/
│ ├── docker-compose.yml
│ ├── nginx.conf
│ ├── nginx_internal.conf
│ └── sysconfig-certbot.j2
└── uninstall.yml
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/CODEOWNERS
================================================
* @Nutomic @dessalines @codyro @ticoombs
================================================
FILE: .gitignore
================================================
inventory/*
================================================
FILE: .woodpecker.yml
================================================
steps:
prettier_markdown_check:
image: jauderho/prettier:3.8.1-alpine
commands:
- prettier -c "*.md" "*.yml" "examples/vars.yml"
when:
- event: pull_request
check_ansible_format:
image: pipelinecomponents/ansible-lint:0.79.11
commands:
- ansible-playbook lemmy.yml --syntax-check
- ansible-playbook lemmy-almalinux.yml --syntax-check
- ansible-playbook uninstall.yml --syntax-check
when:
- event: pull_request
ansible_lint:
image: pipelinecomponents/ansible-lint:0.79.11
commands:
- ansible-lint --warn-list experimental lemmy.yml lemmy-almalinux.yml uninstall.yml examples/vars.yml
when:
- event: pull_request
================================================
FILE: LICENSE
================================================
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
.
================================================
FILE: README.md
================================================
# Lemmy-Ansible
This provides an easy way to install [Lemmy](https://github.com/LemmyNet/lemmy) on any server. It automatically sets up an nginx server, letsencrypt certificates, docker containers, pict-rs, and email smtp.
## Requirements
To run this ansible playbook, you need to:
- Have a Debian/AlmaLinux 9-based server / VPS where lemmy will run.
- Supported CPU architectures are x86-64 and ARM64.
- Configure a DNS `A` Record to point at your server's IP address.
- Make sure you can ssh to it, with a sudo user: `ssh @`
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) (>= `2.11.0` on your **local** machine (do not install it on your destination server)).
### Supported Distribution Playbook Matrix
These are the distributions we currently support. Anything not listed here is currently not supported.
If you wish to see another distribution on the list, please test on the latest commit in `main` and report your findings via an Issue.
| Distribution | Version | Playbook |
| ------------ | --------- | --------------------- |
| Debian | 11 | `lemmy.yml` |
| Debian | 12 | `lemmy.yml` |
| Debian | 13 | `lemmy.yml` |
| Ubuntu | 22.04 LTS | `lemmy.yml` |
| RHEL | 9 | `lemmy-almalinux.yml` |
## Install
1. Clone this repo & checkout latest tag
```
git clone https://github.com/LemmyNet/lemmy-ansible.git
cd lemmy-ansible
git checkout $(git describe --tags)
```
2. Make a directory to hold your config:
`mkdir -p inventory/host_vars/`
3. Copy the sample configuration file:
`cp examples/config.hjson inventory/host_vars//config.hjson`
Edit that file and change the config to your liking. Note: **Do not edit anything inside the {{ }} braces.**
[Here are all the config options.](https://join-lemmy.org/docs/en/administration/configuration.html#full-config-with-default-values)
4. Copy the sample inventory hosts file:
`cp examples/hosts inventory/hosts`
Edit the inventory hosts file (inventory/hosts) to your liking.
5. Copy the sample postgresql.conf
`cp examples/customPostgresql.conf inventory/host_vars//customPostgresql.conf`
You can use [the PGTune tool](https://pgtune.leopard.in.ua) to tune your postgres to meet your server memory and CPU.
6. Copy the sample `vars.yml` file
`cp examples/vars.yml inventory/host_vars//vars.yml`
Edit the `inventory/host_vars//vars.yml` file to your liking.
7. Install the ansible requirements
`ansible-galaxy install -r requirements.yml`
8. Run the playbook:
_Note_: See the "Supported Distribution Playbook Matrix" section above if you should use `lemmy.yml` or not
`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:
`ansible-playbook -i inventory/hosts lemmy.yml --become --ask-become-pass`
_Note_: if you haven't set up ssh keys[^1], and ssh using a password, use the command:
`ansible-playbook -i inventory/hosts lemmy.yml --become --ask-pass --ask-become-pass`
[Full ansible command-line docs](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html)
If the command above fails, you may need to comment out this line In the ansible.cfg file:
`interpreter_python=/usr/bin/python3`
[^1]: To create an ssh key pair with your host environment, you can follow the [instructions here](https://www.ssh.com/academy/ssh/keygen#copying-the-public-key-to-the-server), and then copy the key to your host server.
## Upgrading
Please see the dedicated [UPGRADING](UPGRADING.md) document for all upgrade processess
Since version `1.1.0` we no longer default to using `main` but use tags to make sure deployments are versioned.
With every new release all migration steps shall be written in the [UPGRADING](UPGRADING.md) document.
When updating please make sure you 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 read.
## Migrating your existing install to use this deploy
- [Follow this guide](https://join-lemmy.org/docs/en/administration/backup_and_restore.html) to backup your existing install.
- Run `docker-compose stop` to stop lemmy.
- Move your docker folders on the server to `/`.
- Copy your postgres password to `inventory/host_vars//passwords/postgres`.
- Follow the install guide above, making sure your `config.hjson` is the same as your backup.
## Uninstall
`ansible-playbook -i inventory/hosts uninstall.yml --become`
## License
- [AGPL License](/LICENSE)
================================================
FILE: UPGRADING.md
================================================
# Upgrading
This file shows all steps in how to upgrade between "versions" of the lemmy-ansible repository.
While we specify a version of Lemmy, pict-rs, postgres, etc. at the point in time we make a release, it does not mean that you cannot mix-and-match versions. (ie; you can run pictrs 0.5.10 with Lemmy 0.19.3).
While you are not forced into running the specific versions, we do not go through thorough testing on all version compatibility matrices, so please make your best judgement and always backup before performing updates.
## General Upgrade Instructions
Before upgrading to a new version, check the [join-lemmy news](https://join-lemmy.org/news) and the specific instructions below for any breaking changes. If none are listed it is enough to run the following steps in your local `lemmy-ansible` folder:
- Find the [latest version](https://github.com/LemmyNet/lemmy-ansible/releases)
- Fetch the updated files: `git pull && git checkout *version_name*`
- Run the deployment: `ansible-playbook -i inventory/hosts lemmy.yml --become`
## Specific Version Upgrades
### Upgrading to 1.5.0 (Lemmy 0.19.4, Pict-rs 0.5, postgres 16)
> **DO NOT RUN IT WITHOUT READING THIS WHOLE SECTION**
This is a major release which requires you to update postgres to v16, and pictrs to v0.5. Once that is done proceed with your regular deployments.
#### Postgres Upgrade from v15 to v16
You need to migrate from postgres v15 to v16. A helper script is provided, that dumps your database, swaps postgres container versions, starts them, and then imports the backup into the new container.
There will be downtime, and it is a little scary as it will be deleting the `volumes/postgres` folder. The only backup you have during this time will be the `15_16_dump.sql`, created by the helper script.
On my reference instance (4 CPU, 8GB Memory, 30GB volumes/postgres), it took 10 minutes to dump the backup, and another 20 minutes to import it again. The biggest time sink when importing is when it recreates the indexes.
If you have a faster system and no noisy neighbours you could get the dump and import to be below 20 minutes, but I'd aim for a 60 minute maintenace window.
- The script you need to download and push onto your server: [postgres_15_to_16_upgrade.sh](https://github.com/LemmyNet/lemmy/blob/main/scripts/postgres_15_to_16_upgrade.sh).
```
# Go to your lemmy directory with the docker-compose.yml
cd /srv/lemmy/{my_lemmy_domain}/
# Download the upgrade script
sudo wget -O postgres_15_to_16_upgrade.sh "https://raw.githubusercontent.com/LemmyNet/lemmy/main/scripts/postgres_15_to_16_upgrade.sh"
# Run the script. Be aware that it may take > 20 minutes
sudo sh postgres_15_to_16_upgrade.sh
```
- This also creates a backup file of your old database, called `15_16_dump.sql`. **Do not delete this file** until you are sure that everything is working correctly, for at least a few days.
#### Pictrs 0.4 -> 0.5 Upgrade
`0.19.4` also adds functionality only supported by pictrs version `0.5`. Follow the [v0.4 -> v0.5 migration guide](https://git.asonix.dog/asonix/pict-rs.git#0-4-to-0-5-migration-guide) to make sure that your pictrs env vars in `vars.yml` are correct.
There are more detailed pictrs upgrade instructions below.
#### Steps
- `git checkout main && git pull && git checkout 1.5.0`
- Check the diff between the two versions to see the changes our examples:
- examples/customPostgresql.conf: We added a new autoexplain & stats feature, & enabled jit after v16 upgrade. \
- On low memory systems, you might want to disable jit still: `jit=0`
- examples/hosts: Add `lemmy_web_port` to have a dedicated port
- examples/vars.yml: Add `postgres_shm` to have the correct shared memory for postgres
- Confirm you are already running Postgres v16
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become`
### Upgrading to 1.4.0 (Lemmy 0.19.3 & Pict-rs 0.5.4)
This is a semi-major release which upgrades pict-rs to 0.5 which has support for postgres as a backend. This configuration is **not supported** by lemmy-ansible for the moment.
#### Steps
- `git pull && git checkout 1.4.0`
- Read [Pictrs' Configuration Changes](https://git.asonix.dog/asonix/pict-rs/#configuration-updates)
- Amend your `vars.yml` file to respect the new changes
- Optional: Add: `PICTRS__UPGRADE__CONCURRENCY` with a value between 32 and 512 depending on how much RAM/CPU you want to dedicate to the upgrade process. A value of 32 used about 2.5GB of RAM for the migration.
- Optional: Curl `/internal/prepare_upgrade` to minimise downtime while upgrading. See [the instructions below](https://github.com/LemmyNet/lemmy-ansible#update-your-pict-rs-sled-database-optional) or the official documentation [here](https://git.asonix.dog/asonix/pict-rs/releases#user-content-upgrade-preparation-endpoint)
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become`
### Upgrading to 1.3.0 (Lemmy 0.19.0 & Pict-rs 0.4.7)
This is a major change and has required reading! tl;dr
- Lemmy has been upgraded to 0.19.0
- pict-rs has been upgraded to 0.4.7
- pict-rs has not been integrated with postgres yet
- "Optional Modules" are now available to be added to your lemmy install as provided by the community.
- The first being pictrs-safety
#### Steps
- Prepare to have downtime as the database needs to perform migrations!
- Run `git pull && git checkout 1.3.0`
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become`
- Lemmy will now be down! In testing this takes from 20 to 60 minutes.
- If you are bored you can ssh into your server, and check the logs on postgres for updates
- `docker compose logs -f postgres` while ssh'd and in your Lemmy directory
#### Update your pict-rs sled-database (Optional)
If you are happy for pict-rs to be down _for a while_ ~go straight to our `1.3.1` git tag which updates pictrs to 0.5.0~. Otherwise keep reading.
Starting with 0.5.0 your database will automatically upgrade to the latest version, which will cause downtime for your users.
As such there is an intermediary step where you can upgrade your database in the background to prepare for 0.5 (Reference documentation)[https://git.asonix.dog/asonix/pict-rs/releases#user-content-upgrade-preparation-endpoint]. This ensure no-one is caught out by unforseen downtime of multiple services.
Once you have deployed lemmy-ansible `1.3.0` tag, please continue (if you want):
- Take note of what your pict-rs API Key is under `vars.yml`
- Take note of what your docker network name is. (It's normally the domain without any extra characters)
- You should be able to find it via: `docker network ls | grep _default` if in doubt.
- Run the following command replacing `api-key` with the pict-rs api key, & `youdomain` with the network name.
- `docker run --network yourdomain_default --rm curlimages/curl:8.5.0 --silent -XPOST -H'X-Api-Token: api-key' 'http://pictrs:8080/internal/prepare_upgrade'`
- This will start the background process updating your database from 0.4 to 0.5 compatible.
This is only Optional, and takes a shorter amount of time than the Lemmy database upgrade, but on huge installations it may take a lot longer.
#### Optional Module(s)
Our first optional module is [pictrs-safety](https://github.com/db0/pictrs-safety). See the repo linked for more information, especially for integration with pictrs (which is what it is for) Thanks to @db0 for their contribution.
See the `pictrs_safety_env_vars` under `examples/vars.yml` for relevant options (and the two password variables)
To enable this module to be used you must ADD `pictrs_safety: true` to your `vars.yml`.
### Upgrading to 1.2.1 (Lemmy 0.18.5)
This is a minor change which fixes the issue with the Postgres container not using the `customPostgres.conf` file.
#### Steps
- Please regenerate your `customPostgres.conf` from `examples/customPostgres.conf`
- **OR**
- Add the following block to your current customPostgres file.
```
# Listen beyond localhost
listen_addresses = '\*'
```
### Upgrading to 1.2.0 (Lemmy 0.18.5)
Major changes:
- All variables are not under a singular file so you will not need to modify anything: `inventory/host_vars/{{ domain }}/vars.yml`
- `--become` is now optional instead of forced on
#### Steps
- Run `git pull && git checkout 1.2.0`
- When upgrading from older versions of these playbooks, you will need to do the following:
- Rename `inventory/host_vars/{{ domain }}/passwords/postgres` file to `inventory/host_vars/{{ domain }}/passwords/postgres.psk`
- Copy the `examples/vars.yml` file to `inventory/host_vars/{{ domain }}/vars.yml`
- Edit your variables as desired
- Run your regular deployment. Example: `ansible-playbook -i inventory/hosts lemmy.yml --become`
### Upgrading to 1.1.0 (Lemmy 0.18.3)
- No major changes should be required
================================================
FILE: VERSION
================================================
0.19.18
================================================
FILE: ansible.cfg
================================================
[defaults]
inventory = inventory
# interpreter_python = /usr/bin/python3
[ssh_connection]
pipelining = True
================================================
FILE: examples/config.hjson
================================================
{
# for more info about the config, check out the documentation
# https://join-lemmy.org/docs/en/administration/configuration.html
database: {
host: postgres
password: "{{ postgres_password }}"
# Alternative way:
#uri: "postgresql://lemmy:{{ postgres_password }}@postgres/lemmy"
}
hostname: "{{ domain }}"
pictrs: {
url: "http://pictrs:8080/"
api_key: "{{ postgres_password }}"
}
email: {
smtp_server: "postfix:25"
smtp_from_address: "noreply@{{ domain }}"
tls_type: "none"
}
}
================================================
FILE: examples/customPostgresql.conf
================================================
# This is an example from: https://pgtune.leopard.in.ua/ (You should create your own)
# DB Version: 15
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 8 GB
# CPUs num: 4
# Data Storage: ssd
max_connections = 200
# This needs to match your `postgres_shm: 2g` in `vars.yml` (It's 'GB' here, and 'g' in vars.yml)
shared_buffers = 2GB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
checkpoint_completion_target = 0.9
checkpoint_timeout = 86400
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 = 30GB
max_worker_processes = 4
max_parallel_workers_per_gather = 2
max_parallel_workers = 4
max_parallel_maintenance_workers = 2
# Other custom params
synchronous_commit=off
# This one shouldn't be on regularly, because DB migrations often take a long time
# statement_timeout = 10000
# Listen beyond localhost
listen_addresses = '*'
# Fix a memory leak issue with postgres 15
# https://github.com/LemmyNet/lemmy/issues/4406
#jit = 0
# Autoexplain and take stats by default
shared_preload_libraries = 'auto_explain,pg_stat_statements'
auto_explain.log_min_duration = 5000ms
================================================
FILE: examples/hosts
================================================
[lemmy]
# to get started, copy this file to `inventory` and adjust the values below.
# - `myuser@example.com`: replace with the destination you use to connect to your server via ssh
# - `ansible_user=root`: replace `root` with your the username you use to connect to your ssh server
# - `domain=example.com`: replace `example.com` with your lemmy domain
# - `letsencrypt_contact_email=your@email.com` replace `your@email.com` with your email address,
# to get notifications if your ssl cert expires
# - `lemmy_base_dir=/srv/lemmy`: the location on the server where lemmy can be installed, can be any folder
# if you are upgrading from a previous version, set this to `/lemmy`
# - `lemmy_version`: The back end version.
# - `lemmy_ui_version`: overrides the front end version.
# - `pictrs_safety`: If true, a docker container for pictrs-safety will be deployed and pict-rs
# will be configured to validate images through it. You will also need to set up a
# fedi-safety worker to validate the images.
# - `lemmy_web_port`: Sets the host->docker nginx upstream port to allow a static host nginx configuration
example.com ansible_user=root domain=example.com letsencrypt_contact_email=your@email.com lemmy_base_dir=/srv/lemmy pictrs_safety=false lemmy_web_port=9633
[all:vars]
ansible_connection=ssh
================================================
FILE: examples/vars.yml
================================================
postgres_password: "{{ lookup('password', 'inventory/host_vars/{{ domain }}/passwords/postgres.psk chars=ascii_letters,digits') }}" # noqa yaml[line-length]
# Next two only relevant if pictrs_safety == True
pictrs_safety_worker_auth: "{{ lookup('password', 'inventory/host_vars/{{ domain }}/passwords/pictrs_safety_worker_auth.psk chars=ascii_letters,digits length=15') }}" # noqa yaml[line-length]
pictrs_safety_secret: "{{ lookup('password', 'inventory/host_vars/{{ domain }}/passwords/pictrs_safety_secret.psk chars=ascii_letters,digits length=80') }}" # noqa yaml[line-length]
# You can set any pict-rs environmental variables here. They will populate the templates/docker-compose.yml file.
# https://git.asonix.dog/asonix/pict-rs
pictrs_env_vars:
- PICTRS__SERVER__API_KEY: "{{ postgres_password }}"
- PICTRS__MEDIA__ANIMATION__MAX_WIDTH: 256
- PICTRS__MEDIA__ANIMATION__MAX_HEIGHT: 256
- PICTRS__MEDIA__ANIMATION__MAX_AREA: 65536
- PICTRS__MEDIA__ANIMATION__MAX_FRAME_COUNT: 400
- PICTRS__MEDIA__VIDEO__ENABLE: "True"
- PICTRS__MEDIA__VIDEO__MAX_FILE_SIZE: 20
- PICTRS_OPENTELEMETRY_URL: http://otel:4137
- RUST_LOG: info
- RUST_BACKTRACE: full
# Edit these for Object Storage
# - PICTRS__STORE__TYPE: object_storage
# - PICTRS__STORE__ENDPOINT: ''
# - PICTRS__STORE__BUCKET_NAME: ''
# - PICTRS__STORE__REGION: ''
# - PICTRS__STORE__USE_PATH_STYLE: false
# - PICTRS__STORE__ACCESS_KEY: ''
# - PICTRS__STORE__SECRET_KEY: ''
# Edit these if you use postgres for your pictrs backend
# - PICTRS__OLD_REPO__PATH=/mnt/sled-repo
# - PICTRS__REPO__TYPE=postgres
# - PICTRS__REPO__URL=postgres://user:password@host:5432/db
postgres_env_vars:
- POSTGRES_USER: lemmy
- POSTGRES_PASSWORD: "{{ postgres_password }}"
- POSTGRES_DB: lemmy
postgres_shm: 2g
lemmy_env_vars:
- RUST_LOG: warn
lemmyui_env_vars:
- LEMMY_UI_LEMMY_INTERNAL_HOST: lemmy:8536
- LEMMY_UI_LEMMY_EXTERNAL_HOST: "{{ domain }}"
- LEMMY_UI_HTTPS: true
postfix_env_vars:
- POSTFIX_myhostname: "{{ domain }}"
pictrs_safety_env_vars:
# Use this in your fedi-safety to allow your worker to authenticate to pictrs-safety
- FEDIVERSE_SAFETY_WORKER_AUTH: "{{ pictrs_safety_worker_auth }}"
- FEDIVERSE_SAFETY_IMGDIR: "/tmp/images"
- USE_SQLITE: 1
- secret_key: "{{ pictrs_safety_secret }}"
- SCAN_BYPASS_THRESHOLD: 10
- MISSING_WORKER_THRESHOLD: 5
# docker-compose default resolver is 127.0.0.11 while podman-compose is 10.89.0.1
nginx_internal_resolver: "{{ '127.0.0.11' if ansible_facts['os_family'] != 'RedHat' else '10.89.0.1' }}"
================================================
FILE: files/docker-daemon.json
================================================
{
"log-driver": "json-file",
"log-opts": {
"max-file": "10",
"max-size": "100m"
},
"live-restore": true
}
================================================
FILE: files/proxy_params
================================================
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
================================================
FILE: lemmy-almalinux.yml
================================================
---
- name: Install Lemmy
hosts: all
gather_facts: true
pre_tasks:
- name: Assert that Ansible version is >= 2.11.0
delegate_to: localhost
ansible.builtin.assert:
that:
- "ansible_version.full is version('2.11.0', '>=')"
fail_msg: "This playbook requires Ansible 2.11.0 or higher"
become: false
# This is not needed for this playbook as it predates its existence
# But we're keeping it for funsies :)
- name: Check lemmy_base_dir
ansible.builtin.fail:
msg: "`lemmy_base_dir` is unset. if you are upgrading from an older version, add `lemmy_base_dir=/lemmy` to your inventory file."
when: lemmy_base_dir is not defined
- name: Check for legacy passwords/postgres file
delegate_to: localhost
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/passwords/postgres"
register: postgres_password_file
become: false
- name: Legacy use of passwords/postgres file
delegate_to: localhost
ansible.builtin.fail:
msg: >-
In current versions of the Lemmy Ansible playbooks, the passwords/postgres file must be renamed to passwords/postgres.psk.
See https://github.com/LemmyNet/lemmy-ansible#upgrading
when: postgres_password_file.stat.exists
become: false
- name: Check for vars.yml file
delegate_to: localhost
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/vars.yml"
register: vars_file
become: false
- name: Missing vars.yml file
delegate_to: localhost
ansible.builtin.fail:
msg: >-
Missing vars.yml file, please refer to the installations instructions. See https://github.com/LemmyNet/lemmy-ansible#install
and https://github.com/LemmyNet/lemmy-ansible#upgrading
when: not vars_file.stat.exists
become: false
- name: Load the vars.yml files
ansible.builtin.include_vars:
file: "inventory/host_vars/{{ domain }}/vars.yml"
handlers:
- name: Reload nginx
ansible.builtin.systemd:
name: nginx
state: reloaded
- name: Reload firewalld
ansible.builtin.systemd:
name: firewalld
state: reloaded
vars:
lemmy_port: "{{ 32767 | random(start=1024) }}"
tasks:
- name: Ensure target system is >= EL9
ansible.builtin.assert:
that:
- ansible_distribution in ['AlmaLinux', 'CentOS', 'RedHat', 'Rocky']
- ansible_distribution_major_version | int >= 9
fail_msg: "This playbook requires Enterprise Linux 9 or greater on the target server"
tags:
- always
- name: Enable CRB repository
ansible.builtin.yum_repository:
name: almalinux-crb
description: AlmaLinux $releasever - CRB
mirrorlist: https://mirrors.almalinux.org/mirrorlist/$releasever/crb
gpgcheck: true
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9
enabled: true
tags:
- dependencies
- name: Install epel-release
ansible.builtin.dnf:
state: present
name: epel-release
tags:
- dependencies
- name: Install dependencies
ansible.builtin.dnf:
state: present
name:
- certbot
- cronie
- curl
- nginx
- podman
- podman-compose
- podman-docker
- python3-certbot-nginx
- python3-docker
- python3-pip
- python3-podman
- python3-virtualenv
- python3-setuptools
tags:
- dependencies
- name: Gather service facts
ansible.builtin.service_facts:
tags:
- firewalld
- name: Allow http/httpd traffic to public zone in firewalld
ansible.posix.firewalld:
service: "{{ item }}"
state: enabled
zone: public
permanent: true
immediate: true
loop:
- http
- https
when: "'firewalld.service' in ansible_facts.services and ansible_facts.services['firewalld.service'].state == 'running'"
tags:
- firewalld
- name: Adjust SELinux to allow HTTPD scripts and modules to connect to the network
ansible.posix.seboolean:
name: httpd_can_network_connect
state: true
persistent: true
tags:
- nginx
- selinux
- name: Start and enable nginx.service
ansible.builtin.systemd:
name: nginx.service
state: started
enabled: true
tags:
- certbot
- certbot_initial
- nginx
- ssl
# TODO: certbot logic needs to be re-worked
- name: Request initial letsencrypt certificate
ansible.builtin.command: certbot certonly --nginx --agree-tos --cert-name '{{ domain }}' -d '{{ domain }}' -m '{{ letsencrypt_contact_email }}'
args:
creates: "/etc/letsencrypt/live/{{ domain }}/privkey.pem"
tags:
- certbot
- certbot_initial
- ssl
- name: Create lemmy folder
ansible.builtin.file:
path: "{{ item.path }}"
owner: "{{ item.owner }}"
state: directory
mode: "0755"
loop:
- path: "{{ lemmy_base_dir }}/{{ domain }}/"
owner: "root"
- path: "{{ lemmy_base_dir }}/{{ domain }}/volumes/"
owner: "root"
- path: "{{ lemmy_base_dir }}/{{ domain }}/volumes/pictrs/"
owner: "991" # Matches docker-compose UID in docker-compose.yml
- path: "/var/cache/lemmy/{{ domain }}/"
owner: "www-data"
tags:
- directories
- name: Set lemmy_port fact
ansible.builtin.set_fact:
lemmy_port: "{{ lemmy_web_port | default(32767 | random(start=1024)) }}"
tags:
- always
- name: Distribute docker/podman templates
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
- src: "templates/docker-compose.yml"
dest: "{{ lemmy_base_dir }}/{{ domain }}/docker-compose.yml"
mode: "0600"
- src: "templates/nginx_internal.conf"
dest: "{{ lemmy_base_dir }}/{{ domain }}/nginx_internal.conf"
mode: "0644"
vars:
lemmy_docker_image: "docker.io/dessalines/lemmy:{{ lemmy_version | default(lookup('file', 'VERSION')) }}"
lemmy_docker_ui_image: "docker.io/dessalines/lemmy-ui:{{ lemmy_ui_version | default(lemmy_version | default(lookup('file', 'VERSION'))) }}"
tags:
- docker
- podman
# TODO: Move to templates/, keeping consistent with upstream currently
# to ensure documentation is accurate
- name: Add the config.hjson
ansible.builtin.template:
# src: "templates/{{ domain }}/config.hjson"
src: "inventory/host_vars/{{ domain }}/config.hjson"
dest: "{{ lemmy_base_dir }}/{{ domain }}/lemmy.hjson"
mode: "0600"
owner: "1000" # Match UID in container
group: "1000" # Match GID in container
tags:
- configs
# TODO: Move to files/, keeping consistent with upstream currently
# to ensure documentation is accurate
- name: Add the customPostgresql.conf
ansible.builtin.template:
# src: "files/{{ domain }}/customPostgresql.conf"
src: "inventory/host_vars/{{ domain }}/customPostgresql.conf"
dest: "{{ lemmy_base_dir }}/{{ domain }}/customPostgresql.conf"
mode: "0644"
owner: root
group: root
tags:
- configs
- postgresql
- name: Distribute nginx proxy_params configuration
ansible.builtin.copy:
src: files/proxy_params
dest: "{{ lemmy_base_dir }}/{{ domain }}/proxy_params"
owner: root
group: root
mode: "0644"
tags:
- nginx
- name: Distribute nginx site templates
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
- src: "templates/nginx.conf"
dest: "/etc/nginx/conf.d/{{ domain }}.conf"
mode: "0644"
notify: Reload nginx
tags:
- nginx
# TODO: Check if this is necessary with EL & podman
# - name: Copy docker config
# ansible.builtin.copy:
# src: "{{ ansible_playbook }}/files/docker-daemon.json"
# dest: /etc/docker/daemon.json
# mode: '0644'
# TODO: podman-compose should wrap this safely
# TODO: This was an incorrect assumption, module uses docker python module, not cli
# - name: Run podman-compose
# docker_compose:
# project_src: "{{ lemmy_base_dir }}/{{ domain }}"
# state: present
# pull: yes
# remove_orphans: yes
# tags:
# - docker
# - docker_compose
# - podman
# - podman_compose
- name: Start and enable podman service
ansible.builtin.systemd:
name: podman.service
state: started
enabled: true
tags:
- docker
- podman
- name: Run podman-compose pull
ansible.builtin.command: podman-compose pull
args:
chdir: "{{ lemmy_base_dir }}/{{ domain }}"
changed_when: true
tags:
- docker
- podman
- name: Run podman-compose up
ansible.builtin.command: podman-compose up -d
args:
chdir: "{{ lemmy_base_dir }}/{{ domain }}"
changed_when: true
tags:
- docker
- podman
# This isn't using any jinja2 templating currently
- name: Distribute /etc/sysconfig/certbot
ansible.builtin.template:
src: "templates/sysconfig-certbot.j2"
dest: "/etc/sysconfig/certbot"
mode: "0644"
tags:
- certbot
- ssl
- name: Enable certbot-renew.timer
ansible.builtin.systemd:
name: certbot-renew.timer
state: started
enabled: true
tags:
- certbot
- ssl
================================================
FILE: lemmy.yml
================================================
---
- name: Install Lemmy
hosts: all
# Install python if required
# https://www.josharcher.uk/code/ansible-python-connection-failure-ubuntu-server-1604/
gather_facts: false
pre_tasks:
- name: Assert that Ansible version is >= 2.11.0
delegate_to: localhost
ansible.builtin.assert:
that:
- "ansible_version.full is version('2.11.0', '>=')"
fail_msg: "This playbook requires Ansible 2.11.0 or higher"
become: false
tags:
- always
- name: Check lemmy_base_dir
ansible.builtin.fail:
msg: "`lemmy_base_dir` is unset. if you are upgrading from an older version, add `lemmy_base_dir=/lemmy` to your inventory file."
when: lemmy_base_dir is not defined
tags:
- always
- name: Check for legacy passwords/postgres file
delegate_to: localhost
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/passwords/postgres"
register: postgres_password_file
become: false
tags:
- always
- name: Legacy use of passwords/postgres file
delegate_to: localhost
ansible.builtin.fail:
msg: >-
In current versions of the Lemmy Ansible playbooks, the passwords/postgres file must be renamed to passwords/postgres.psk.
See https://github.com/LemmyNet/lemmy-ansible#upgrading
when: postgres_password_file.stat.exists
become: false
tags:
- always
- name: Check for vars.yml file
delegate_to: localhost
ansible.builtin.stat:
path: "inventory/host_vars/{{ domain }}/vars.yml"
register: vars_file
become: false
tags:
- always
- name: Missing vars.yml file
delegate_to: localhost
ansible.builtin.fail:
msg: >-
Missing vars.yml file, please refer to the installations instructions. See https://github.com/LemmyNet/lemmy-ansible#install
and https://github.com/LemmyNet/lemmy-ansible#upgrading
when: not vars_file.stat.exists
become: false
tags:
- always
- name: Load the vars.yml files
ansible.builtin.include_vars:
file: "inventory/host_vars/{{ domain }}/vars.yml"
- name: Install python for Ansible
# python2-minimal instead of python-minimal for ubuntu 20.04 and up
ansible.builtin.raw: test -e /usr/bin/python || test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal python3-setuptools)
args:
executable: /bin/bash
register: output
changed_when: output.stdout != ''
tags:
- always
- dependencies
- name: Gather facts
ansible.builtin.setup:
tags:
- always
handlers:
- name: Reload nginx
ansible.builtin.systemd:
name: nginx
state: reloaded
tasks:
- name: Ensure target system is Debian or Ubuntu
ansible.builtin.assert:
that:
- ansible_distribution in ['Debian', 'Ubuntu']
fail_msg: "This playbook requires Debian or Ubuntu on the target server"
tags:
- always
- name: Install dependencies
ansible.builtin.apt:
state: present
update_cache: true
pkg:
- "nginx"
- "certbot"
- "python3-certbot-nginx"
- "apt-transport-https"
- "ca-certificates"
- "curl"
- "gnupg"
- "python3-pip"
- "virtualenv"
- "python3-setuptools"
- "cron"
tags:
- dependencies
- name: Configure Docker apt repo for Ubuntu < 22.04
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version < '22.04'
tags:
- dependencies
- docker
block:
- name: Add Docker GPG apt Key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
state: present
- name: Get architecture using dpkg
when: (ansible_distribution == 'Debian') or
(ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '22.04')
ansible.builtin.command: dpkg --print-architecture
register: dpkg_output
changed_when: false
tags:
- dependencies
- docker
# based on https://docs.docker.com/engine/install/debian/
# and https://docs.docker.com/engine/install/ubuntu/
# note that Debian and Ubuntu use the same key
- name: Configure Docker apt repo for Debian < 12 or Ubuntu >= 22.04
when:
(ansible_distribution == 'Debian' and ansible_distribution_version | int < 12) or
(ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '22.04')
tags:
- dependencies
- docker
block:
- name: Download Docker GPG Key
ansible.builtin.get_url:
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
dest: /etc/apt/trusted.gpg.d/docker.asc
checksum: sha256:1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570
mode: "0644"
- name: Add Docker apt repo
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ dpkg_output.stdout }} signed-by=/etc/apt/trusted.gpg.d/docker.asc]
https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
state: present
- name: Configure Docker apt repo for Debian >= 13 (Trixie)
when: (ansible_distribution == 'Debian' and ansible_distribution_version | int >= 12)
tags:
- dependencies
- docker
block:
- name: Download Docker GPG Key
ansible.builtin.get_url:
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
dest: /etc/apt/keyrings/docker.asc
checksum: sha256:1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570
mode: "0644"
- name: Add Docker apt repo
ansible.builtin.deb822_repository:
name: docker
types: deb
uris: https://download.docker.com/linux/{{ ansible_distribution | lower }}
suites: "{{ ansible_distribution_release }}"
components: stable
signed_by: /etc/apt/keyrings/docker.asc
state: present
- name: Install docker-ce and docker-compose
ansible.builtin.apt:
name:
- containerd.io
- docker-ce
- docker-buildx-plugin
- docker-compose-plugin
state: present
update_cache: true
tags:
- dependencies
- docker
- name: Copy docker config
ansible.builtin.copy:
src: files/docker-daemon.json
dest: /etc/docker/daemon.json
mode: "0644"
tags:
- docker
- name: Request initial letsencrypt certificate
ansible.builtin.command: certbot certonly --nginx --agree-tos --cert-name '{{ domain }}' -d '{{ domain }}' -m '{{ letsencrypt_contact_email }}'
args:
creates: "/etc/letsencrypt/live/{{ domain }}/privkey.pem"
tags:
- certbot
- certbot_initial
- ssl
- name: Create lemmy folder
ansible.builtin.file:
path: "{{ item.path }}"
owner: "{{ item.owner }}"
state: directory
mode: "0755"
loop:
- path: "{{ lemmy_base_dir }}/{{ domain }}/"
owner: "root"
- path: "{{ lemmy_base_dir }}/{{ domain }}/volumes/"
owner: "root"
- path: "{{ lemmy_base_dir }}/{{ domain }}/volumes/pictrs/"
owner: "991"
- path: "/var/cache/lemmy/{{ domain }}/"
owner: "www-data"
tags:
- directories
- name: Deploy configuration files
block:
- name: Generate random port for lemmy service
ansible.builtin.set_fact:
lemmy_port: "{{ lemmy_web_port | default(32767 | random(start=1024)) }}"
- name: Distribute nginx proxy_params configuration
ansible.builtin.copy:
src: files/proxy_params
dest: "{{ lemmy_base_dir }}/{{ domain }}/proxy_params"
owner: root
group: root
mode: "0644"
notify: Reload nginx
tags:
- configs
- nginx
- name: Add template files
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
- src: "templates/docker-compose.yml"
dest: "{{ lemmy_base_dir }}/{{ domain }}/docker-compose.yml"
mode: "0600"
- src: "templates/nginx_internal.conf"
dest: "{{ lemmy_base_dir }}/{{ domain }}/nginx_internal.conf"
mode: "0644"
- src: "templates/nginx.conf"
dest: "/etc/nginx/sites-available/{{ domain }}.conf"
mode: "0644"
notify: Reload nginx
vars:
lemmy_docker_image: "dessalines/lemmy:{{ lemmy_version | default(lookup('file', 'VERSION')) }}"
lemmy_docker_ui_image: "dessalines/lemmy-ui:{{ lemmy_ui_version | default(lemmy_version | default(lookup('file', 'VERSION'))) }}"
tags:
- configs
- nginx
- docker
- name: Set up nginx sites-enabled symlink
notify: Reload nginx
tags:
- configs
- nginx
block:
- name: Gather stats on site enabled config
ansible.builtin.stat:
path: "/etc/nginx/sites-enabled/{{ domain }}.conf"
register: reg_enabled
- name: Remove if regular file (legacy) instead of symlink
ansible.builtin.file:
path: "/etc/nginx/sites-enabled/{{ domain }}.conf"
state: absent
when: reg_enabled.stat.exists and reg_enabled.stat.isreg
- name: Enable nginx site
ansible.builtin.file:
src: "../sites-available/{{ domain }}.conf"
dest: "/etc/nginx/sites-enabled/{{ domain }}.conf"
state: link
- name: Add the config.hjson
ansible.builtin.template:
src: "inventory/host_vars/{{ domain }}/config.hjson"
dest: "{{ lemmy_base_dir }}/{{ domain }}/lemmy.hjson"
mode: "0600"
owner: "1000"
group: "1000"
tags:
- configs
- name: Add the customPostgresql.conf
ansible.builtin.template:
src: "inventory/host_vars/{{ domain }}/customPostgresql.conf"
dest: "{{ lemmy_base_dir }}/{{ domain }}/customPostgresql.conf"
mode: "0644"
owner: root
group: root
tags:
- configs
- postgresql
- name: Enable and start docker service
ansible.builtin.systemd:
name: docker
enabled: true
state: started
tags:
- docker
- name: Start docker-compose
community.docker.docker_compose_v2:
project_src: "{{ lemmy_base_dir }}/{{ domain }}"
state: present
pull: always
remove_orphans: true
tags:
- docker
- name: Certbot renewal cronjob
ansible.builtin.cron:
special_time: daily
name: certbot-renew-lemmy
user: root
job: "certbot certonly --nginx --cert-name '{{ domain }}' -d '{{ domain }}' --deploy-hook 'nginx -s reload'"
tags:
- certbot
- ssl
================================================
FILE: renovate.json
================================================
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"schedule": ["before 4am on the first day of the month"],
"automerge": true
}
================================================
FILE: requirements.yml
================================================
---
collections:
- name: ansible.posix
- name: community.docker
================================================
FILE: templates/docker-compose.yml
================================================
x-logging: &default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "4"
services:
proxy:
image: docker.io/library/nginx
ports:
# Note, change lemmy_port in vars.yml if it is already in use on your system
- "127.0.0.1:{{ lemmy_port }}:8536"
volumes:
- ./nginx_internal.conf:/etc/nginx/nginx.conf:ro,Z
- ./proxy_params:/etc/nginx/proxy_params:ro,Z
restart: always
logging: *default-logging
depends_on:
postgres:
condition: service_healthy
pictrs:
condition: service_started
lemmy:
image: {{ lemmy_docker_image }}
hostname: lemmy
restart: always
logging: *default-logging
{% if lemmy_env_vars is defined and lemmy_env_vars|length > 0 %}
environment:
{% for item in lemmy_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
volumes:
- ./lemmy.hjson:/config/config.hjson:Z
depends_on:
postgres:
condition: service_healthy
pictrs:
condition: service_started
lemmy-ui:
image: {{ lemmy_docker_ui_image }}
{% if lemmyui_env_vars is defined and lemmyui_env_vars|length > 0 %}
environment:
{% for item in lemmyui_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
volumes:
- ./volumes/lemmy-ui/extra_themes:/app/extra_themes:Z
depends_on:
lemmy:
condition: service_started
restart: always
logging: *default-logging
pictrs:
image: docker.io/asonix/pictrs:0.5
# this needs to match the pictrs url in lemmy.hjson
hostname: pictrs
# we can set options to pictrs like this, here we set max. image size and forced format for conversion
# entrypoint: /sbin/tini -- /usr/local/bin/pict-rs -p /mnt -m 4 --image-format webp
{% if pictrs_env_vars is defined and pictrs_env_vars|length > 0 %}
environment:
{% for item in pictrs_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
{% if pictrs_safety is defined and pictrs_safety|bool == true %}
- PICTRS__MEDIA__EXTERNAL_VALIDATION=http://{{ domain }}:14051/api/v1/scan/IPADDR
{% endif %}
user: 991:991
volumes:
- ./volumes/pictrs:/mnt:Z
restart: always
logging: *default-logging
postgres:
image: docker.io/pgautoupgrade/pgautoupgrade:16-alpine
hostname: postgres
{% if postgres_env_vars is defined and postgres_env_vars|length > 0 %}
environment:
{% for item in postgres_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
volumes:
- ./volumes/postgres:/var/lib/postgresql/data:Z
- ./customPostgresql.conf:/etc/postgresql.conf:Z
restart: always
command: postgres -c config_file=/etc/postgresql.conf
shm_size: {{ postgres_shm }}
logging: *default-logging
postfix:
image: docker.io/mwader/postfix-relay
{% if postfix_env_vars is defined and postfix_env_vars|length > 0 %}
environment:
{% for item in postfix_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
restart: "always"
logging: *default-logging
{% if pictrs_safety is defined and pictrs_safety|bool == true %}
pictrs-safety:
image: ghcr.io/db0/pictrs-safety:v1.2.2
hostname: pictrs-safety
{% if pictrs_safety_env_vars is defined and pictrs_safety_env_vars|length > 0 %}
environment:
{% for item in pictrs_safety_env_vars %}
{% for key, value in item.items() %}
- {{ key }}={{ value }}
{% endfor %}
{% endfor %}
{% endif %}
ports:
- "14051:14051"
user: 991:991
restart: always
logging: *default-logging
depends_on:
pictrs:
condition: service_started
{% endif %}
================================================
FILE: templates/nginx.conf
================================================
limit_req_zone $binary_remote_addr zone={{ domain }}_ratelimit:10m rate=1r/s;
proxy_cache_path /var/cache/lemmy/{{domain}}/ levels=1:2 keys_zone=lemmy_cache_{{domain|replace(".","_")|replace("-","_")}}:10m max_size=100m use_temp_path=off;
proxy_cache_key $scheme$proxy_host$request_uri$http_accept$slice_range;
slice 1m;
server {
listen 80;
listen [::]:80;
server_name {{ domain }};
# Hide nginx version
server_tokens off;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ domain }};
ssl_certificate /etc/letsencrypt/live/{{ domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ domain }}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets on;
# Hide nginx version
server_tokens off;
# Upload limit, relevant for pictrs
client_max_body_size 20M;
# Enable compression for JS/CSS/HTML bundle, for improved client load times.
gzip on;
gzip_types text/css application/javascript image/svg+xml text/javascript;
gzip_vary on;
# Various content security headers
add_header Referrer-Policy "same-origin";
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "DENY";
add_header X-XSS-Protection "1; mode=block";
location / {
proxy_pass http://0.0.0.0:{{lemmy_port}};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Range $slice_range;
proxy_cache lemmy_cache_{{domain|replace(".","_")|replace("-","_")}};
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_no_cache $cookie_jwt $http_authorization;
proxy_cache_bypass $cookie_jwt $http_authorization;
# for debugging, should probably be disabled in prod
#add_header x-cache-status $upstream_cache_status;
}
}
access_log /var/log/nginx/access.log combined;
================================================
FILE: templates/nginx_internal.conf
================================================
worker_processes auto;
events {
worker_connections 1024;
}
http {
# Docker internal DNS IP so we always get the newer containers without having to
# restart/reload the docker container / nginx configuration
resolver {{ nginx_internal_resolver }} valid=5s;
# set the real_ip when from docker internal ranges. Ensuring our internal nginx
# container can always see the correct ips in the logs
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
# We construct a string consistent of the "request method" and "http accept header"
# and then apply soem ~simply regexp matches to that combination to decide on the
# HTTP upstream we should proxy the request to.
#
# Example strings:
#
# "GET:application/activity+json"
# "GET:text/html"
# "POST:application/activity+json"
#
# You can see some basic match tests in this regex101 matching this configuration
# https://regex101.com/r/vwMJNc/1
#
# Learn more about nginx maps here http://nginx.org/en/docs/http/ngx_http_map_module.html
map "$request_method:$http_accept" $proxpass {
# If no explicit matches exists below, send traffic to lemmy-ui
default "http://lemmy-ui:1234";
# GET/HEAD requests that accepts ActivityPub or Linked Data JSON should go to lemmy.
#
# These requests are used by Mastodon and other fediverse instances to look up profile information,
# discover site information and so on.
"~^(?:GET|HEAD):.*?application\/(?:activity|ld)\+json" "http://lemmy:8536";
# All non-GET/HEAD requests should go to lemmy
#
# Rather than calling out POST, PUT, DELETE, PATCH, CONNECT and all the verbs manually
# we simply negate the GET|HEAD pattern from above and accept all possibly $http_accept values
"~^(?!(GET|HEAD)).*:" "http://lemmy:8536";
}
server {
set $lemmy_ui "lemmy-ui:1234";
set $lemmy "lemmy:8536";
# this is the port inside docker, not the public one yet
listen 1236;
listen 8536;
# change if needed, this is facing the public web
server_name localhost;
server_tokens off;
# Upload limit, relevant for pictrs
client_max_body_size 20M;
# Send actual client IP upstream
include proxy_params;
# frontend general requests
location / {
proxy_pass $proxpass;
rewrite ^(.+)/+$ $1 permanent;
}
# security.txt
location = /.well-known/security.txt {
proxy_pass "http://$lemmy_ui";
}
# backend
location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known|version|sitemap.xml) {
proxy_pass "http://$lemmy";
# Send actual client IP upstream
include proxy_params;
}
}
}
================================================
FILE: templates/sysconfig-certbot.j2
================================================
## NOTE ##
# If a hook is set here then it will be used for all
# certificates and will override any per certificate
# hook configuration in place.
# Command to be run in a shell before obtaining any
# certificates. Intended primarily for renewal, where it
# can be used to temporarily shut down a webserver that
# might conflict with the standalone plugin. This will
# only be called if a certificate is actually to be
# obtained/renewed. When renewing several certificates
# that have identical pre-hooks, only the first will be
# executed.
#
# An example to stop the MTA before updating certs would be
# PRE_HOOK="--pre-hook 'systemctl stop postfix'"
PRE_HOOK=""
# Command to be run in a shell after attempting to
# obtain/renew certificates. Can be used to deploy
# renewed certificates, or to restart any servers that
# were stopped by --pre-hook. This is only run if an
# attempt was made to obtain/renew a certificate. If
# multiple renewed certificates have identical post-
# hooks, only one will be run.
#
# An example to restart httpd would be:
# POST_HOOK="--post-hook 'systemctl restart httpd'"
POST_HOOK="'nginx -s reload'"
# Command to be run in a shell once for each
# successfully renewed certificate. For this command,
# the shell variable $RENEWED_LINEAGE will point to the
# config live subdirectory containing the new certs and
# keys; the shell variable $RENEWED_DOMAINS will contain
# a space-delimited list of renewed cert domains
#
# An example to run a script to alert each cert would be:
# DEPLOY_HOOK="--deploy-hook /usr/local/bin/cert-notifier.sh"
DEPLOY_HOOK=""
# Any other misc arguments for the renewal
# See certbot -h renew for full list
#
# An example to force renewal for certificates not due yet
# CERTBOT_ARGS="--force-renewal"
CERTBOT_ARGS=""
================================================
FILE: uninstall.yml
================================================
---
- name: Uninstall Lemmy
hosts: all
vars_prompt:
- name: confirm_uninstall
prompt: "Do you really want to uninstall Lemmy? This will delete all data and can not be reverted [yes/no]"
private: false
- name: delete_certs
prompt: "Delete certificates? Select 'no' if you want to reinstall Lemmy [yes/no]"
private: false
- name: stop_disable_nginx
prompt: "Do you want to stop/disable nginx? [yes/no]"
private: false
- name: stop_disable_docker_podman
prompt: "Do you want to stop/disable Docker/podman? [yes/no]"
private: false
tasks:
- name: Inform about cancellation if no confirmation was given
ansible.builtin.debug:
msg: "Uninstall cancelled, doing nothing"
when: not confirm_uninstall | bool
- name: End play if no confirmation was given
ansible.builtin.meta: end_play
when: not confirm_uninstall | bool
- name: Run Debian/Ubuntu specific uninstallation steps
when: ansible_distribution in ['Debian', 'Ubuntu']
block:
- name: Stop docker-compose
community.docker.docker_compose_v2:
project_src: "{{ lemmy_base_dir }}/{{ domain }}"
state: absent
- name: Delete data
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items:
- path: "{{ lemmy_base_dir }}/{{ domain }}"
- path: "/etc/nginx/sites-enabled/{{ domain }}.conf"
- name: Remove certbot cronjob
ansible.builtin.cron:
name: certbot-renew-lemmy
state: absent
- name: Stop and disable Docker
ansible.builtin.systemd:
name: docker.service
state: stopped
enabled: false
when: stop_disable_docker_podman | bool
- name: Run EL specific uninstallation steps
when:
- ansible_distribution in ['AlmaLinux', 'CentOS', 'RedHat', 'Rocky']
- ansible_distribution_major_version | int >= 9
block:
- name: Stop and remove containers
ansible.builtin.command: podman-compose down
args:
chdir: "{{ lemmy_base_dir }}/{{ domain }}"
changed_when: true
- name: Delete Lemmy data
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop:
- path: "{{ lemmy_base_dir }}/{{ domain }}"
- path: "/etc/nginx/conf.d/{{ domain }}.conf"
- name: Stop and disable certbot-renew.timer
ansible.builtin.systemd:
name: certbot-renew.timer
state: stopped
enabled: false
- name: Stop and disable podman
ansible.builtin.systemd:
name: podman.service
state: stopped
enabled: false
when: stop_disable_docker_podman | bool
- name: Stop and disable nginx
ansible.builtin.systemd:
name: nginx.service
state: stopped
enabled: false
when: stop_disable_nginx | bool