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