Browse Source

1yr-old; first commit

master
Y 1 year ago
commit
4bd3c54bbf
100 changed files with 5647 additions and 0 deletions
  1. 674
    0
      LICENSE
  2. 134
    0
      README.adoc
  3. 543
    0
      bootstrap.adoc
  4. 501
    0
      group_vars/all
  5. 8
    0
      group_vars/back
  6. 8
    0
      group_vars/front
  7. 9
    0
      group_vars/front_chroot
  8. 9
    0
      production
  9. 6
    0
      roles/_maintenance_start/defaults/main.yml
  10. 25
    0
      roles/_maintenance_start/tasks/main.yml
  11. 6
    0
      roles/_maintenance_stop/defaults/main.yml
  12. 27
    0
      roles/_maintenance_stop/tasks/main.yml
  13. 6
    0
      roles/acme_back/defaults/main.yml
  14. 12
    0
      roles/acme_back/files/dehydrated.timer
  15. 10
    0
      roles/acme_back/handlers/main.yml
  16. 9
    0
      roles/acme_back/meta.OK/main.yml
  17. 85
    0
      roles/acme_back/tasks/main.yml
  18. 12
    0
      roles/acme_back/templates/dehydrated.config.j2
  19. 109
    0
      roles/acme_back/templates/hook.sh.j2
  20. 6
    0
      roles/acme_front/defaults/main.yml
  21. 10
    0
      roles/acme_front/handlers/main.yml
  22. 7
    0
      roles/acme_front/meta.OK/main.yml
  23. 31
    0
      roles/acme_front/tasks/main.yml
  24. 98
    0
      roles/aur.inc/tasks/install.yml
  25. 27
    0
      roles/aur.inc/tasks/main.yml
  26. 6
    0
      roles/cleanupdate/defaults/main.yml
  27. 7
    0
      roles/cleanupdate/meta.OK/main.yml
  28. 44
    0
      roles/cleanupdate/tasks/main.yml
  29. 7
    0
      roles/ddclient.inc/meta.OK/main.yml
  30. 46
    0
      roles/ddclient.inc/tasks/main.yml
  31. 6
    0
      roles/ddclient_FreeDNS_example/defaults/main.yml
  32. 10
    0
      roles/ddclient_FreeDNS_example/handlers/main.yml
  33. 7
    0
      roles/ddclient_FreeDNS_example/meta.OK/main.yml
  34. 59
    0
      roles/ddclient_FreeDNS_example/tasks/main.yml
  35. 6
    0
      roles/ddclient_HE_example/defaults/main.yml
  36. 10
    0
      roles/ddclient_HE_example/handlers/main.yml
  37. 7
    0
      roles/ddclient_HE_example/meta.OK/main.yml
  38. 73
    0
      roles/ddclient_HE_example/tasks/main.yml
  39. 6
    0
      roles/dmz_dotclear_front/defaults/main.yml
  40. 10
    0
      roles/dmz_dotclear_front/handlers/main.yml
  41. 7
    0
      roles/dmz_dotclear_front/meta.OK/main.yml
  42. 69
    0
      roles/dmz_dotclear_front/tasks/main.yml
  43. 29
    0
      roles/dmz_dotclear_front/templates/config.php.j2
  44. 108
    0
      roles/dmz_dotclear_front/templates/ldap_auth.php.j2
  45. 6
    0
      roles/dmz_exim/defaults/main.yml
  46. 15
    0
      roles/dmz_exim/files/example.org_dkim.privk.pem
  47. 22
    0
      roles/dmz_exim/handlers/main.yml
  48. 8
    0
      roles/dmz_exim/meta.OK/main.yml
  49. 585
    0
      roles/dmz_exim/tasks/main.yml
  50. 6
    0
      roles/dmz_haproxy/defaults/main.yml
  51. 10
    0
      roles/dmz_haproxy/handlers/main.yml
  52. 9
    0
      roles/dmz_haproxy/meta.OK/main.yml
  53. 79
    0
      roles/dmz_haproxy/tasks/main.yml
  54. 73
    0
      roles/dmz_haproxy/templates/haproxy.conf.j2
  55. 6
    0
      roles/dmz_ihmgit_front/defaults/main.yml
  56. 10
    0
      roles/dmz_ihmgit_front/handlers/main.yml
  57. 7
    0
      roles/dmz_ihmgit_front/meta.OK/main.yml
  58. 30
    0
      roles/dmz_ihmgit_front/tasks/main.yml
  59. 6
    0
      roles/dmz_ihmldap/defaults/main.yml
  60. 10
    0
      roles/dmz_ihmldap/handlers/main.yml
  61. 8
    0
      roles/dmz_ihmldap/meta.OK/main.yml
  62. 184
    0
      roles/dmz_ihmldap/tasks/main.yml
  63. 6
    0
      roles/dmz_movim_front/defaults/main.yml
  64. 16
    0
      roles/dmz_movim_front/handlers/main.yml
  65. 9
    0
      roles/dmz_movim_front/meta.OK/main.yml
  66. 135
    0
      roles/dmz_movim_front/tasks/main.yml
  67. 6
    0
      roles/dmz_nextcloud_front/defaults/main.yml
  68. 10
    0
      roles/dmz_nextcloud_front/handlers/main.yml
  69. 7
    0
      roles/dmz_nextcloud_front/meta.OK/main.yml
  70. 32
    0
      roles/dmz_nextcloud_front/tasks/main.yml
  71. 49
    0
      roles/dmz_nextcloud_front/templates/nginx_lool.j2
  72. 58
    0
      roles/dmz_nextcloud_front/templates/nginx_nextcloud.j2
  73. 6
    0
      roles/dmz_nginx/defaults/main.yml
  74. 19
    0
      roles/dmz_nginx/handlers/main.yml
  75. 8
    0
      roles/dmz_nginx/meta.OK/main.yml
  76. 248
    0
      roles/dmz_nginx/tasks/main.yml
  77. 7
    0
      roles/dmz_nginx/templates/00.http.inc.j2
  78. 54
    0
      roles/dmz_nginx/templates/10.conf.j2
  79. 7
    0
      roles/dmz_nginx/templates/filters.inc.j2
  80. 17
    0
      roles/dmz_nginx/templates/php-fast.inc.j2
  81. 32
    0
      roles/dmz_nginx/templates/php-full.inc.j2
  82. 6
    0
      roles/dmz_prosody_front/defaults/main.yml
  83. 16
    0
      roles/dmz_prosody_front/handlers/main.yml
  84. 9
    0
      roles/dmz_prosody_front/meta.OK/main.yml
  85. 330
    0
      roles/dmz_prosody_front/tasks/main.yml
  86. 141
    0
      roles/dmz_prosody_front/templates/xep0363_http_upload.php.j2
  87. 6
    0
      roles/dmz_wallabag_front/defaults/main.yml
  88. 10
    0
      roles/dmz_wallabag_front/handlers/main.yml
  89. 8
    0
      roles/dmz_wallabag_front/meta.OK/main.yml
  90. 101
    0
      roles/dmz_wallabag_front/tasks/main.yml
  91. 6
    0
      roles/dotclear_back/defaults/main.yml
  92. 7
    0
      roles/dotclear_back/meta.OK/main.yml
  93. 28
    0
      roles/dotclear_back/tasks/main.yml
  94. 6
    0
      roles/dovecot/defaults/main.yml
  95. 10
    0
      roles/dovecot/handlers/main.yml
  96. 9
    0
      roles/dovecot/meta.OK/main.yml
  97. 91
    0
      roles/dovecot/tasks/main.yml
  98. 26
    0
      roles/dovecot/templates/dovecot-ldap-passdb.conf.j2
  99. 148
    0
      roles/dovecot/templates/dovecot.conf.j2
  100. 0
    0
      roles/etckeeper.inc/tasks/init.yml

+ 674
- 0
LICENSE View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for
software and other kinds of works.

The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.

Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and
modification follow.

TERMS AND CONDITIONS

0. Definitions.

"This License" refers to version 3 of the GNU General Public License.

"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.

To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

A "covered work" means either the unmodified Program or a work based
on the Program.

To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

1. Source Code.

The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.

A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

The Corresponding Source for a work in source code form is that
same work.

2. Basic Permissions.

All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.

3. Protecting Users' Legal Rights From Anti-Circumvention Law.

No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

4. Conveying Verbatim Copies.

You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

5. Conveying Modified Source Versions.

You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.

b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".

c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.

d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.

A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

6. Conveying Non-Source Forms.

You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.

b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.

c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.

d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.

e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.

A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

7. Additional Terms.

"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or

b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or

c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or

d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or

e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or

f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.

All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

8. Termination.

You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

9. Acceptance Not Required for Having Copies.

You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

10. Automatic Licensing of Downstream Recipients.

Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.

An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

11. Patents.

A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".

A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

12. No Surrender of Others' Freedom.

If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

13. Use with the GNU Affero General Public License.

Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

14. Revised Versions of this License.

The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

15. Disclaimer of Warranty.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 134
- 0
README.adoc View File

@@ -0,0 +1,134 @@
/////
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
/////

= Automated configuration of a home-server
:toc:

== Introduction

This project contains a collection of https://docs.ansible.com/[Ansible] rules, that:

* both automate and document the setup of a home-server, as secure as possible;
* should greatly ease the quick setup of a replacement server, in case the main one has a hardware failure (this is for a single machine, not a datacenter).

Let it be clear, that the target is a *home*-server, not an entreprise solution, not a personal VM “in the Cloud”, but a real hardware machine plugged at home to the xDSL or fiber router, that links you to an ISP.
Besides, this project should not be used without *solid knowledge of Linux and its command-line, as well as https://git-scm.com/[Git]*!

Oh! And I decided to let go of Debian, and use https://www.archlinux.org/[Archlinux] instead.
Someone once questionned me about such a choice for a server; here was my answer:

[quote, Yves, https://linuxfr.org/news/pyruse-1-0-pour-remplacer-fail2ban-et-autres-scruteurs-de-journaux-sur-un-gnu-linux-moderne#comment-1729871]
_____
In practice, Archlinux is working pretty well on a server. Before that, I was using Debian.
My experience (for a server) is such:

Archlinux::
* `−` There is almost always something to handle after software upgrades ⇒ I never let these upgrades run automatically unsupervised.
* `+` On the other hand, the solutions to the problems that arise are always simple, and I know that I can handle them.
* `+` Moreover, the software is always up-to-date, which makes exploring new use-cases so much easier!
* `+` Finally, it is trivial to package new software, as I did with https://yalis.fr/git/yves/pyruse/[Pyruse]; this allows me to avoid `./configure && make install` steps in my Ansible playbook.

Debian::
* `+` Updates usually just happen, almost unnoticed.
* `−` But when there _is_ a failure, I have to delve into Debian’s idiosyncrasies, and this is not always easy…
* `+` Security updates are done in a serious way, which compensates for the age of the packets.
* `−` But as time passes, some software becomes complicated, or even impossible in some cases, to test.

Everything is in the personal balance that suits you.
I am perfectly comfortable with the command line, and Archlinux is better suited to my goals.
But one should not be dogmatic: other Linux distributions may be better suited to other situations.
_____

== What can the server do?

Here is what is currently available (I will not repeat “automated” every time, since everything is done with Ansible):

* a container acting as a https://en.wikipedia.org/wiki/DMZ_(computing)[DMZ], which is the only part of the server, that the Internet can reach;
* firewalls (one for the DMZ, the other for the backend server);
* as much https://freedesktop.org/wiki/Software/systemd/[systemd] as possible (almost all logs, the DMZ, network, ntp, dns…);
* systemd journals’ scrutation with automatic reporting of urgent situations, and a daily report;
* `/etc` changes followed in Git, with a separation between the upstream state (branch `master`) and the everyday state (branch `run`);
* certificate renewal using the https://letsencrypt.org/how-it-works/[ACME protocol], and certificate deployment to the locations where the software needs it;
* software upgrades;
* https://en.wikipedia.org/wiki/Dynamic_DNS[dynamic DNS] handling (remember, this is a _home_ server, where a fixed IPv4 address is not a given);
* centralized handling of users in https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol[LDAP];
* a web portal and https://en.wikipedia.org/wiki/Single_sign-on[SSO], to reach the different web services for registered users;
* a web https://en.wikipedia.org/wiki/User_interface[UI] for handling LDAP entries and mail aliases (also in LDAP);
* mail handling, with SMTP and IMAP;
* a PostgreSQL database;
* an SSH server, hidden with https://en.wikipedia.org/wiki/Port_knocking[port-knocking];
* a web server configured to allow additional contents for clients who port-knocked properly;
* a https://en.wikipedia.org/wiki/Blog[blog];
* a web UI for the Git projects hosted on the server;
* a “personal cloud”, for files (https://en.wikipedia.org/wiki/WebDAV[WebDAV]), contacts (https://en.wikipedia.org/wiki/CardDAV[CardDAV]), and calendars (https://en.wikipedia.org/wiki/CalDAV[CalDAV]), all (and more!) freely synchronizable with an https://www.fairphone.com/en/[Android smartphone];
* automatic mounting of the “personal cloud” files when logging in on the server;
* an https://en.wikipedia.org/wiki/Network_File_System[NFS] server;
* an https://en.wikipedia.org/wiki/XMPP[XMPP] server;
* a print server;
* a scan server;
* a remote-controlled media server (requires audio and video outputs);
* a https://en.wikipedia.org/wiki/Digital_Living_Network_Alliance[DLNA]/uPNP server;
* a private https://en.wikipedia.org/wiki/Pastebin[pastebin]-like service;
* a https://en.wikipedia.org/wiki/BitTorrent[BitTorrent] server;
* a https://github.com/yarrick/iodine[DNS tunnel];
* a SSH-over-link:https://en.wikipedia.org/wiki/Transport_Layer_Security[TLS] tunnel;
* https://en.wikipedia.org/wiki/Bonjour_(software)[Bonjour]-SD (Service-Discovery);
* a web UI for bookmarks (work in progress…);
* a web XMPP client (work in progress…).

== Current status

This configuration has led to a working server, which has been up and running for more than a year.
However:

* the Ansible rules written here still have rough edges;
* this is a quick (one might say hasty) publishing of the current Ansible rules, and they’re in need of way more documentation…

This project is also a way for me to _learn_ Ansible, and I’d be happy to know if I misused Ansible somewhere `:-)`

== Requirements

A domain name is needed.
It is expected that DNS entries are handled by an external service, because the home-server does not do that itself.
For example, https://dns.he.net/[Hurricane Electric] can be used. +
For testing purposes, a free temporary domain may be used, for example at https://freedns.afraid.org/[Free DNS].

At home, the server needs to be connected to a router that has these properties:

* allows machines on the LAN to have a fixed IP: the server, and also all terminals (PC, Android…) that shall be trusted;
* has a “DMZ mode” (ie. route all incoming Internet traffic — with possible exceptions — to a chosen IP on the LAN), or at least port-by-port NAT;
* is a gateway to the Internet for LAN machines;
* allows all incoming and outgoing traffic (most notably SMTP, which tends to be blocked by default);

The server itself should have at least 2GB of RAM, and at least 2 CPU cores (for better multitasking).
On my https://www.udoo.org/udoo-x86/[Basic Udoo X86] (2GB RAM and 4× https://ark.intel.com/fr/products/92124/Intel-Atom-x5-E8000-Processor-2M-Cache-up-to-2_00-GHz[x5-E8000]@1.04GHz CPU), with all of the above services running, I get good performance, 60% RAM used, and an average system load of 8%, which is rather good!

Last but not least, the machine that will run the Ansible playbook should have a version of Ansible greater than 2.2:

* module `include_role` runs dynamically (available since version 2.4);
* modules `ini_file`, `lineinfile`, `mount`, and `replace` use the `path` parameter (available since version 2.3);
* modules `ldap_attr` and `ldap_entry` are used (available since version 2.3);
* module `lineinfile` uses the `firstmatch` parameter (available since version 2.5);
* module `user` uses the `create_home` parameter (available since version 2.5).

Also, this machine must have a static IP address on the LAN, because only this computer will be allowed to run Ansible commands on the server, using the dedicated SSH key.

== Usage

First, the server must be link:bootstrap.adoc[prepared, so that Ansible can connect and run the rules].

Then the rules are run by launching this command at the root of the project:

```bash
$ ansible-playbook -i production site.yml
```

[literal.small]
.....
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
.....

+ 543
- 0
bootstrap.adoc View File

@@ -0,0 +1,543 @@
/////
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
/////

:keymap: fr-bepo
:front-name: dmz
:front-ip: 192.168.1.254
:back-name: home
:back-ip: 192.168.1.253
:pc-ip: 192.168.1.252
:net-bits: 24
:net-gateway: 192.168.1.1
:your-uid: me
:sys-disk: /dev/mmcblk0
:sys-esp: /dev/mmcblk0p1
:sys-pv: /dev/mmcblk0p2
:sys-vg: Sys
:data-vg: Data
:appdata-lv: AppData
:userdata-lv: UserData
:bt-storage-name: p2p
:bt-storage-todo: iso.torrent
:bt-storage-doing: .iso.wip
:bt-storage-done: iso
:prosody-db: prosody
:prosody-db-user: prosody
:nextcloud-db: nextcloud
:nextcloud-db-user: nextcloud
:nextcloud-root: /usr/share/webapps/nextcloud
:nextcloud-user: cloud

= Bootstrap of the home-server
:toc:

TIP: Modifiy this document’s header variables and it will then reflect your own preferences.
https://addons.mozilla.org/fr/firefox/addon/asciidoctorjs-live-preview/[View the result in Firefox].

== Purpose

The server is entirely configured by https://docs.ansible.com/[Ansible].
Thus, what this document is about should be entirely done with Ansible.
However, Ansible can only reach and control the server if the server has some basic software installed (namely, SSH and Python), and has its network interface correctly configured.
This is a chicken-and-egg problem, which is solved by manually bootstraping the server.

== Archlinux standard installation

Once the Archlinux installation media (USB in my case) is inserted and booted (in EFI mode), the https://wiki.archlinux.org/index.php/Installation_guide[official documentation] basically comes down to this (to be adapted for your actual preferences):

Basic configuration and partioning::
* `{sys-disk}` is the small integrated storage area, where the system gets installed.
* The “{data-vg}” LVM-VG is a (set of) storage device(s) (SATA, eSATA, or USB3) with lots of extra space (for example on `/dev/sdb`).
* Each application that manages state data gets its own mount points inside a BTRFS “{appdata-lv}” volume.
* User data is stored in a BTRFS “{userdata-lv}” volume.
+
[subs="+attributes"]
```bash
root@archiso ~ # export LVM=/dev/mapper
root@archiso ~ # export DMZ=/mnt/var/lib/machines/{front-name}
root@archiso ~ # export APPDATA=/mnt/mnt/AppData
root@archiso ~ # export USERDATA=/mnt/mnt/UserData

root@archiso ~ # loadkeys {keymap}
root@archiso ~ # ping -c 1 archlinux.org
1 packets transmitted, 1 received, 0% packet loss, time 0ms
root@archiso ~ # timedatectl set-ntp true

root@archiso ~ # fdisk {sys-disk}
Command (m for help): g
Created a new GPT disklabel…

Command (m for help): n
Partition number (1-128, default 1):
First sector (…):
Last sector, +sectors or +size{K,M,G,T,P} (…): +128M

Created a new partition 1…

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Command (m for help): n
Partition number (2-128, default 2):
First sector (…):
Last sector, +sectors or +size{K,M,G,T,P} (…):

Created a new partition 2…

Command (m for help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): 31

Changed type of partition 'Linux filesystem' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

root@archiso ~ # mkfs.vfat -n ESP {sys-esp}
root@archiso ~ # pvcreate {sys-pv}
root@archiso ~ # vgcreate {sys-vg} {sys-pv}
root@archiso ~ # lvcreate -L 5G -n Root {sys-vg}
root@archiso ~ # lvcreate -L 2G -n Cont {sys-vg}
root@archiso ~ # mkfs.ext4 $LVM/{sys-vg}-Root
root@archiso ~ # mkfs.btrfs --mixed --label Cont $LVM/{sys-vg}-Cont
root@archiso ~ # lvcreate -L 10G -n RootVar {data-vg}
root@archiso ~ # mkfs.ext4 $LVM/{data-vg}-RootVar
root@archiso ~ # lvcreate -L 1G -n ContVar {data-vg}
root@archiso ~ # mkfs.ext4 $LVM/{data-vg}-ContVar
root@archiso ~ # lvcreate -L 100G -n {appdata-lv} {data-vg}
root@archiso ~ # mkfs.btrfs --mixed --label {appdata-lv} $LVM/{data-vg}-{appdata-lv}
root@archiso ~ # lvcreate -L 700G -n {userdata-lv} {data-vg}
root@archiso ~ # mkfs.btrfs --mixed --label {userdata-lv} $LVM/{data-vg}-{userdata-lv}
root@archiso ~ # lvcreate -L 1G -n Home {data-vg}
root@archiso ~ # mkfs.ext4 $LVM/{data-vg}-Home
```

Host and guest mounting::
* The hardware host holds the sensitive data, and is not reachable from the Internet.
* the guest container is the DMZ and holds directly accessible Internet services.
+
[subs="+attributes"]
```bash
root@archiso ~ # mount $LVM/{sys-vg}-Root /mnt
root@archiso ~ # mkdir -p /mnt/{boot,home,var} $APPDATA $USERDATA
root@archiso ~ # mount LABEL=ESP /mnt/boot
root@archiso ~ # mount $LVM/{data-vg}-Home /mnt/home
root@archiso ~ # mount $LVM/{data-vg}-RootVar /mnt/var
root@archiso ~ # mount $LVM/{data-vg}-{appdata-lv} $APPDATA
root@archiso ~ # mkdir -p /mnt/var/cache/{minidlna,pacman/pkg}
root@archiso ~ # mkdir -p \
> /mnt/var/lib/{acme,dovecot,gitea,kodi,machines,nextcloud,openldap,postgres}
root@archiso ~ # mkdir -p /mnt/var/spool/mail

root@archiso ~ # btrfs subvolume create $APPDATA/acme.lib
root@archiso ~ # btrfs subvolume create $APPDATA/acme.srv
root@archiso ~ # btrfs subvolume create $APPDATA/ddclient.cache
root@archiso ~ # btrfs subvolume create $APPDATA/dovecot.lib
root@archiso ~ # btrfs subvolume create $APPDATA/gitea.lib
root@archiso ~ # btrfs subvolume create $APPDATA/kodi.lib
root@archiso ~ # btrfs subvolume create $APPDATA/mail.spool
root@archiso ~ # btrfs subvolume create $APPDATA/minidlna.cache
root@archiso ~ # btrfs subvolume create $APPDATA/movim.cache
root@archiso ~ # btrfs subvolume create $APPDATA/movim.lib
root@archiso ~ # btrfs subvolume create $APPDATA/nextcloud.lib
root@archiso ~ # btrfs subvolume create $APPDATA/nginx.log
root@archiso ~ # btrfs subvolume create $APPDATA/openldap.lib
root@archiso ~ # btrfs subvolume create $APPDATA/pacman_pkg.cache
root@archiso ~ # btrfs subvolume create $APPDATA/postgres.lib
root@archiso ~ # btrfs subvolume create $APPDATA/prosody.lib
root@archiso ~ # btrfs subvolume create $APPDATA/transmission.lib
root@archiso ~ # btrfs subvolume create $APPDATA/webapps.srv

root@archiso ~ # mount \
> -o subvol=acme.lib,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/acme
root@archiso ~ # mount \
> -o subvol=dovecot.lib,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/dovecot
root@archiso ~ # mount \
> -o subvol=gitea.lib,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/gitea
root@archiso ~ # mount \
> -o subvol=kodi.lib,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/kodi
root@archiso ~ # mount \
> -o subvol=mail.spool,compress=lzo,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/spool/mail
root@archiso ~ # mount \
> -o subvol=minidlna.cache,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/cache/minidlna
root@archiso ~ # mount \
> -o subvol=nextcloud.lib,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/nextcloud
root@archiso ~ # mount \
> -o subvol=openldap.lib,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/openldap
root@archiso ~ # mount \
> -o subvol=pacman_pkg.cache,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/cache/pacman/pkg
root@archiso ~ # mount \
> -o subvol=postgres.lib,nodatacow \
> $LVM/{data-vg}-{appdata-lv} /mnt/var/lib/postgres

root@archiso ~ # mount $LVM/{sys-vg}-Cont /mnt/var/lib/machines
root@archiso ~ # btrfs subvolume create $DMZ
root@archiso ~ # mkdir -p $DMZ/var
root@archiso ~ # mount $LVM/{data-vg}-ContVar $DMZ/var
root@archiso ~ # mkdir -p $DMZ/srv/{acme,webapps}
root@archiso ~ # mkdir -p $DMZ/var/cache/{ddclient,movim}
root@archiso ~ # mkdir -p $DMZ/var/lib/{prosody,transmission}
root@archiso ~ # mkdir -p $DMZ/var/log/nginx

root@archiso ~ # mount \
> -o subvol=acme.srv,nodatacow \
> $LVM/{data-vg}-{appdata-lv} $DMZ/srv/acme
root@archiso ~ # mount \
> -o subvol=ddclient.cache,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/cache/ddclient
root@archiso ~ # mount \
> -o subvol=movim.cache \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/cache/movim
root@archiso ~ # mount \
> -o subvol=movim.lib,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/lib/movim
root@archiso ~ # mount \
> -o subvol=nginx.log,compress=lzo,nodatacow \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/log/nginx
root@archiso ~ # mount \
> -o subvol=prosody.lib,nodatacow \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/lib/prosody
root@archiso ~ # mount \
> -o subvol=transmission.lib,nodatacow \
> $LVM/{data-vg}-{appdata-lv} $DMZ/var/lib/transmission
root@archiso ~ # mount \
> -o subvol=webapps.srv,compress=lzo \
> $LVM/{data-vg}-{appdata-lv} $DMZ/srv/webapps

root@archiso ~ # mkdir $DMZ/var/lib/transmission/{Todo,Doing,Done}
root@archiso ~ # mount -o nodatacow $LVM/{data-vg}-{userdata-lv} $USERDATA
root@archiso ~ # mkdir -p $USERDATA/{bt-storage-name}
root@archiso ~ # for d in {bt-storage-todo} {bt-storage-doing} {bt-storage-done}; do
> btrfs subvolume create $USERDATA/{bt-storage-name}/$d
> done

root@archiso ~ # mount \
> -o subvol={bt-storage-name}/{bt-storage-todo},nodatacow \
> $LVM/{data-vg}-{userdata-lv} $DMZ/var/lib/transmission/Todo
root@archiso ~ # mount \
> -o subvol={bt-storage-name}/{bt-storage-doing},nodatacow \
> $LVM/{data-vg}-{userdata-lv} $DMZ/var/lib/transmission/Doing
root@archiso ~ # mount \
> -o subvol={bt-storage-name}/{bt-storage-done},nodatacow \
> $LVM/{data-vg}-{userdata-lv} $DMZ/var/lib/transmission/Done
```

Archlinux installation::
* When this is done, be sure to check that `/mnt/etc/fstab` perfectly matches the wanted result (the above mount points).
+
```bash
root@archiso ~ # pacstrap /mnt base arch-install-scripts intel-ucode \
> openssh python2 etckeeper git lvm2 btrfs-progs rsync
root@archiso ~ # genfstab -L /mnt >>/mnt/etc/fstab
```

Archlinux initial configuration::
* The basic files for the host must roughly match the final configuration, enough to let Ansible control the right host on the right IP without error.
* The values used here *must* match those in link:group_vars/all[].
+
[subs="+attributes"]
```bash
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# echo {back-name} >/etc/hostname
[root@archiso /]# cat >/etc/systemd/network/bridge.netdev <<-"THEEND"
> [NetDev]
> Name=wire
> Kind=bridge
> THEEND
[root@archiso /]# cat >/etc/systemd/network/bridge.network <<-"THEEND"
> [Match]
> Name=wire
>
> [Network]
> IPForward=yes
> Address={back-ip}/{net-bits}
> Gateway={net-gateway}
> THEEND
[root@archiso /]# cat >/etc/systemd/network/wired.network <<-"THEEND"
> [Match]
> Name=en*
>
> [Network]
> Bridge=wire
> THEEND
[root@archiso /]# systemctl enable systemd-networkd.service
[root@archiso /]# sed -i '/prohibit-password/s/.*/PermitRootLogin yes/' \
> /etc/ssh/sshd_config
[root@archiso /]# mkdir ~root/.ssh
[root@archiso /]# chmod 700 ~root/.ssh
[root@archiso /]# scp {your-uid}@{pc-ip}:.ssh/id_ansible.pub \
> ~root/.ssh/authorized_keys
[root@archiso /]# chmod 600 ~root/.ssh/authorized_keys
[root@archiso /]# systemctl enable sshd.service
[root@archiso /]# sed -i '/^HOOKS=/s/block filesystems/block lvm2 filesystems/' \
> /etc/mkinitcpio.conf
[root@archiso /]# mkinitcpio -p linux
[root@archiso /]# passwd
passwd: password updated successfully
[root@archiso /]# bootctl --path=/boot install
[root@archiso /]# cat >/boot/loader/entries/arch.conf <<-THEEND
> title Arch Linux
> linux /vmlinuz-linux
> initrd /intel-ucode.img
> initrd /initramfs-linux.img
> options root=$LVM/{sys-vg}-Root rw
> THEEND
[root@archiso /]# cat >/boot/loader/loader.conf <<-"THEEND"
> default arch
> editor 0
> THEEND
[root@archiso /]# printf '%s, %s\n' \
> 'ACTION=="add", SUBSYSTEM=="usb"' \
> 'TEST=="power/control", ATTR{power/control}="off"' \
> >/etc/udev/rules.d/50-usb_power_save.rules
[root@archiso /]# exit
root@archiso ~ # systemctl reboot
```

This last command about USB and power control disables power saving for USB.
This line is only interesting if the main data drive is connected with USB.

[IMPORTANT]
===========
In theory, at this stage, the machine is ready to be controlled by Ansible.
However, Ansible fails at first, because for some reason, `pacstrap` in the “front” Ansible role fails to initialize the DMZ if the location already contains mount points, so:

. I had to temporarily unmount everything under `/var/lib/machines/{front-name}`, and delete the `/var/lib/machines/{front-name}/usr` sub-diretory.
. I also temporarily commented out the whole front-half of `site.xml`, as well as the “front-run” role of the back part.
. Then I ran Ansible again.
. When the DMZ was correctly initialized, I renamed `/var/lib/machines/{front-name}/var` to `/var/lib/machines/{front-name}/var.new`.
. Then I created a new `/var/lib/machines/{front-name}/var`, inside of which I mounted all the above DMZ-specific mount points again.
. In the `/var/lib/machines/{front-name}/` directory, I ran `rsync -av var.new/ var/`.
. After that, I could remove the `/var.new` directory (see below), restore `site.yml` to its original state, and start Ansible once again.

When I wanted to delete the DMZ’s `var.new` directory as root, I was denied the permission!
This is because `pacstrap` created the DMZ’s own `var/lib/machines` as a btrfs subvolume, which can only be deleted with the `btrfs subvolume delete var.new/lib/machines` command (`var.new` because of the renaming above).
Then removing `var.new` worked.
===========

== Post-installation tasks

You may want to restore some data from a former installation.
This section contains some examples of data restoration.

NOTE: Most values and paths here are examples, and shall be adapted.

=== Dotclear

[subs="+attributes"]
```bash
[root@{back-name} ~]# systemctl -M {front-name} stop haproxy.service
[root@{back-name} ~]# systemctl -M {front-name} stop nginx.service
[root@{back-name} ~]# systemctl -M {front-name} stop php-fpm.service
[root@{back-name} ~]# sudo -u postgres pg_restore -c -C -F c -d postgres \
> </backup/dotclear.cdump
[root@{back-name} ~]# systemctl -M {front-name} start php-fpm.service
[root@{back-name} ~]# systemctl -M {front-name} start nginx.service
[root@{back-name} ~]# systemctl -M {front-name} start haproxy.service
```

=== Prosody

[subs="+attributes"]
```bash
[root@{back-name} ~]# systemctl -M {front-name} stop haproxy.service
[root@{back-name} ~]# systemctl -M {front-name} stop nginx.service
[root@{back-name} ~]# systemctl -M {front-name} stop prosody.service
[root@{back-name} ~]# sudo -u postgres pg_restore -c -C -F c -d postgres \
> </backup/prosody.cdump
[root@{back-name} ~]# su - postgres
[postgres@{back-name} ~]$ psql
postgres=# ALTER DATABASE {prosody-db} OWNER TO {prosody-db-user};
ALTER DATABASE
postgres=# \c {prosody-db}
{prosody-db}=# ALTER TABLE prosody OWNER TO {prosody-db-user};
ALTER TABLE
{prosody-db}=# \q
[postgres@{back-name} ~]$ exit
[root@{back-name} ~]# systemctl -M {front-name} start prosody.service
[root@{back-name} ~]# systemctl -M {front-name} start nginx.service
[root@{back-name} ~]# systemctl -M {front-name} start haproxy.service
```

=== Nextcloud

There is a twist here…

My former installation actually was ownCloud, _not_ Nextcloud.
But knowing that I would use Nextcloud from then on, before doing the backup I upgraded my ownCloud installation to the corresponding compatible Nextcloud version (version `10.0.2.1`). +
The upgrade process broke my ownCloud… Not a big deal, since I only needed the backup of the data, to be restored in a clean Nextcloud installation on the new server.
But I don’t remember if, on the new server, I restored the backup of the migrated database, or the backup of the ownCloud database…

Besides, my old ownCloud did _not_ use LDAP, instead relying on its internal database of users.
Unfortunately, there is no way to convert internal users (with their contacts, calendars, and so on) into LDAP users.
So I did it the programmer’s way, by studying the data model, and running SQL requests.
These are described below.

At the time of the data restoration, the current Nextcloud release (installed on the server) was version `12.…`.

Stop Nextcloud and restore the data::
+
[subs="+attributes"]
```bash
[root@{back-name} ~]# systemctl -M {front-name} stop haproxy.service
[root@{back-name} ~]# systemctl -M {front-name} stop nginx.service
[root@{back-name} ~]# systemctl stop nextcloud-maintenance.timer
[root@{back-name} ~]# systemctl stop uwsgi@nextcloud.socket
[root@{back-name} ~]# systemctl stop uwsgi@nextcloud.service
[root@{back-name} ~]# sudo -u postgres pg_restore -c -C -F c -d postgres \
> </backup/owncloud10.cdump
[root@{back-name} ~]# sed -i "s/'version' => '12.*'/'version' => '10.0.2.1'/" \
> /etc/webapps/nextcloud/config/config.php
[root@{back-name} ~]# cd {nextcloud-root}
[root@{back-name} nextcloud]# sudo -u {nextcloud-user} \
> /usr/bin/env NEXTCLOUD_CONFIG_DIR=/etc/webapps/nextcloud/config \
> /usr/bin/php occ upgrade
[root@{back-name} nextcloud]# cd /etc
[root@{back-name} etc]# git reset --hard
[root@{back-name} etc]# etckeeper init
```

Migrate users to LDAP (they keep the same name)::
* connect to the database:
+
[subs="+attributes"]
```bash
[root@{back-name} etc]# su - postgres
[postgres@{back-name} ~]$ psql
postgres=# ALTER DATABASE {nextcloud-db} OWNER TO {nextcloud-db-user};
ALTER DATABASE
postgres=# \c {nextcloud-db}
{nextcloud-db}=#
```
* browse a table (eg. `addressbooks`) to note the number associated to each user (eg. “`{your-uid}`” associated to number “`6266`”);
* migrate user `{your-uid}` (repeat for each user): the idea is to delete most data, considering that it is sync’ed somewhere and it can be restored by resynchronizing:
+
[subs="+attributes"]
```sql
{nextcloud-db}=# delete from oc_accounts where uid='{your-uid}';
DELETE 1
{nextcloud-db}=# delete from oc_addressbooks where principaluri='principals/users/{your-uid}_6266';
DELETE 1
{nextcloud-db}=# delete from oc_calendars where principaluri='principals/users/{your-uid}_6266';
DELETE 1
{nextcloud-db}=# delete from oc_credentials;
DELETE 0
{nextcloud-db}=# delete from oc_filecache where name='{your-uid}_6266';
DELETE 1
{nextcloud-db}=# delete from oc_jobs where argument='{"uid":"{your-uid}_6266"}';
DELETE 1
{nextcloud-db}=# delete from oc_mounts where user_id like '%{your-uid}_6266%';
DELETE 1
{nextcloud-db}=# delete from oc_preferences where userid='{your-uid}_6266';
DELETE 10
{nextcloud-db}=# delete from oc_storages where id='home::{your-uid}_6266';
DELETE 1
{nextcloud-db}=# delete from oc_users where uid='{your-uid}';
DELETE 1
{nextcloud-db}=# update oc_ldap_user_mapping set owncloud_name='{your-uid}' where owncloud_name='{your-uid}_6266';
UPDATE 1
{nextcloud-db}=# commit;
{nextcloud-db}=# \q
```

Restart Nextcloud::
+
[subs="+attributes"]
```bash
[root@{back-name} ~]# systemctl start uwsgi@nextcloud.socket
[root@{back-name} ~]# systemctl start nextcloud-maintenance.timer
[root@{back-name} ~]# systemctl -M {front-name} start nginx.service
[root@{back-name} ~]# systemctl -M {front-name} start haproxy.service
```

=== Restore emails

I was formerly using BincIMAP, and then Courier-IMAP, and I also ran Dovecot once, on a backup server, when my main server’s power supply burnt.
As a consequence, the Maildirs were polluted with dot-files from various origins.
I decided to do a clean import, especially since I configured Dovecot in a way that makes it more performant, with the constraint that it must have exclusive access to the mail storage.

[subs="+attributes"]
```bash
[root@{back-name} ~]# find /backup/user-Maildirs -depth \
> \( -iname '*binc*' -o -iname '*courier*' -o -iname '*dovecot*' \) \
> -exec rm -rf {} \;
[root@{back-name} ~]# for u in $(ls /backup/user-Maildirs); do
> chown -R $u /backup/user-Maildirs/$u
> doveadm import -s -u $u maildir:/backup/user-Maildirs/$u/Maildir/ '' ALL
> done
```

[literal.small]
.....
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
.....

+ 501
- 0
group_vars/all View File

@@ -0,0 +1,501 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

# Short personal nickname that will be mostly used as part of filenames under /etc.
nickname: personal

# Hostname and IPv4 address of the DMZ.
DMZ: dmz
DMZ_IP: 192.168.1.254

# Hostname and IPv4 address of the back-end server (with all the data).
SafeZone: home
SafeZone_IP: 192.168.1.253

# Domain names that the certificate should cover.
acme_domains: 'example.org www.example.org pubsub.example.org'

# Public key that Ansible will use to manage the server, and IP address of the controller PC.
# The public key (`….pub` file) is generated as the result of running `ssh-keygen -t ed25519`.
ansible_authorized_key: 'ssh-ed25519 AAAA0000bbbb1111CCCC2222dddd3333EEEE4444ffff5555GGGG6666hhhh7777IIII me@my-pc'
ansible_master: 192.168.1.252

# System user that will build packages from AUR (https://aur.archlinux.org/).
aur_user: git

# Just leave this with an empty-string value.
chroot: ''

# https://wiki.archlinux.org/index.php/Keyboard_configuration_in_console
default_keymap: en

# https://jlk.fjfi.cvut.cz/arch/manpages/man/papersize.5
default_papersize: a4

# LDAP (real) user that will have admin rights in Dotclear (the blog).
dotclear_admin_user: me

# Name of the Dotclear database in PostgreSQL.
dotclear_db: dotclear

# PostgreSQL user who owns the Dotclear database.
dotclear_db_user: dotclear

# Password for the PostgreSQL user who owns the Dotclear database.
dotclear_db_password: dotclear

# Dotclear encrypts sensitive data with a master key, that is set here (random string).
dotclear_master_key: 0123456789abcdefghijklmnopqrstuvwxyz

# Location where Dotclear is installed, which *must* end with “/dotclear”
dotclear_root: /srv/webapps/dotclear

# The default locale (https://wiki.archlinux.org/index.php/Locale).
locales_default: 'en_US.UTF-8'

# All installed locales on the server.
locales_enabled: 'en_US.UTF-8 fr_FR.UTF-8 fr_FR@euro'

# Enable DNSSEC in systemd-resolved (“yes” or “no”, as a character string); experimental!
dns_sec: 'no'

# DNS servers to use on the server, for example:
# FDN-1 (v4) FDN-2 (v4) FDN-1 (v6) FDN-2 (v6) OpenNIC-1 OpenNIC-2 Google
dns_hosts: '80.67.169.12 80.67.169.40 2001:910:800::12 2001:910:800::40 87.98.175.85 5.135.183.146 8.8.8.8'

# Nearest NTP servers (https://www.ntppool.org/).
ntp_hosts: '0.uk.pool.ntp.org 1.uk.pool.ntp.org 2.uk.pool.ntp.org 3.uk.pool.ntp.org'

# IP addresses that are allowed to browse DLNA/uPNP contents, even though they are not trusted.
# This is a space-separated list of networks (IP/bits).
# A typical example would be a living-room BD player or TV, which includes a DLNA client.
fw_dlna_clients: 192.168.1.53/32

# Number of minutes allowed between two consecutive ports of the port-knocking sequence.
fw_knock_timeout_min: 2

# Port-knocking sequence. A port may appear multiple times, but not next to each-other.
fw_portknock_seq: 1 22 333 4444 333 22 1

# The email address associated to root, for commits in the git repository that stores changes to /etc.
git_contact_email: hostmaster@example.org

# Name of the Gitea (web UI for Git) database in PostgreSQL.
gitea_db: gitea

# PostgreSQL user who owns the Gitea database.
gitea_db_user: gitea

# Password for the PostgreSQL user who owns the Gitea database.
gitea_db_password: gitea

# Disable creation of organisations in Gitea (“true” or “false”, as a character string).
gitea_disable_org_creation: 'true'

# Disable self-registration in Gitea (“true” or “false”, as a character string).
gitea_disable_registration: 'false'

# Enable email notifications in Gitea (“true” or “false”, as a character string).
gitea_enable_notify_email: 'true'

# Maximum size of HTTP and PHP uploads.
http_max_upload: 10000M

# Document-root of the HTTP server.
http_root: /srv/http

# URL prefix of Dotclear (blog).
http_pfx_dotclear: /blog

# URL prefix of Gitea (web UI for Git).
http_pfx_gitea: /git

# URL prefix of LDAP-Account-Manager (web UI for LDAP).
http_pfx_lam: /account

# URL prefix of Movim (XMPP web client).
http_pfx_movim: /social

# URL prefix of Nextcloud (self-hosted “cloud”).
http_pfx_nextcloud: /cloud

# URL prefix of PrivateBin (self-hosted “pastebin”).
http_pfx_privatebin: /paste

# URL prefix of Prosody-generated URL (file uploads, BOSH, websockets…).
http_pfx_prosody: /xmpp-

# URL prefix of SSOwat (SSO and web portal).
http_pfx_ssowat: /start

# URL prefix of Transmission (web UI for BitTorrent).
http_pfx_transmission: /torrent

# URL prefix of Wallabag (social sharing of bookmarks).
http_pfx_wallabag: /bookmarks

# Subdomain-name that will serve DNS packets for Iodine (DNS tunnel). Choose it short!
iodine_domain: dt.example.org

# Network associated with the DNS tunnel (IP address of the server on this network, “/”, bits for the network-mask).
iodine_net: '172.16.12.1/28'

# Password of the DNS tunnel.
iodine_password: '_t_r___e@6358'

# Location of Kodi state data (not the media contents).
kodi_data: /var/lib/kodi

# System user that will run Kodi.
kodi_user: kodi

# Master password, needed to change LDAP-Account-Manager settings.
lam_master_password: lam

# Password policy for LDAP-Account-Manager (https://www.ldap-account-manager.org/static/doc/manual-onePage/#idm695).
# “-1” means “all”.
lam_checkedRulesCount: -1
lam_passwordMinClasses: 3
lam_passwordMinLength: 10
lam_passwordMinLower: 0
lam_passwordMinNumeric: 0
lam_passwordMinSymbol: 1
lam_passwordMinUpper: 0
lam_passwordMustNotContain3Chars: 'true'
lam_passwordMustNotContainUser: 'true'

# Title for LDAP-Account-Manager in the SSOwat portal.
lam_sso_title: Directory

# Additional ACL for LDAP.
# This is typically used to give extra powers to users, for example regarding aliases management.
ldap_extra_acl: |
access to dn.subtree="ou=Aliases,dc=example,dc=org"
by dn.base="uid=me,ou=Users,dc=example,dc=org" write
by self read
by * read

# Organization-name for this home-server LDAP directory.
ldap_o_name: 'Home'

# Root of the LDAP directory. Usually the domain-name with commas instead of dots, and “dc=” in front of each level.
ldap_root: dc=example,dc=org

# Password of the root user (administrator) in OpenLDAP.
ldap_rootpw: 'OE104995à6&o_zKR4'

# Same password, as expected by OpenLDAP.
# See https://gist.github.com/rca/7217540 (python2) or https://www.openldap.org/faq/data/cache/347.html.
ldap_rootpw_sha: '{SSHA}Raa3TlvDPZTjdM44nKZQt+hDvQRvaMDC'

# Custom system groups and memberships, declared in LDAP.
# This is the right place to declare a group in which to put all real and system users, who will be allowed to read media contents.
ldap_system_groups: '[
{"cn": "registered", "gidNumber": 1200}
{"cn": "media", "gidNumber": 1201}
]'
ldap_system_group_members: '[
{"group": "media", "member": "me"},
{"group": "media", "member": "cloud"},
{"group": "media", "member": "kodi"}
]'

# Real users (ie. with a Linux account on the server) to declare in LDAP.
# Each user in the JSON list contains:
# — uidNumber: a unique user ID, which must be ≥1000;
# — gidNumber: a group ID, which should be a “gidNumber” of ldap_system_groups;
# — uid: the login name, usually short, without spaces, and all lowercase;
# — cn: the user’s firstname;
# — sn: the user’s surname;
# — password: the user’s password upon creation, in the same format as ldap_rootpw_sha (“change_me” in the example).
# These settings are only read when creating the users in LDAP.
ldap_system_users: '[
{"uidNumber": 1000, "gidNumber": 1200, "uid": "you", "cn": "Yule-Offa", "sn": "Udel", "password": "{SSHA}393aKNBzihkeHWXalkw/vpdy3dYHoh5L"},
{"uidNumber": 1001, "gidNumber": 1200, "uid": "me", "cn": "Mae", "sn": "Ellen", "password": "{SSHA}393aKNBzihkeHWXalkw/vpdy3dYHoh5L"}
]'

# Guest users (they can use the provided software, but do not have a Linux account).
# The fields are the same as above, minus the Linux UID and GID numbers.
# These settings are only read when creating the users in LDAP.
ldap_virtual_users: '[
{"uid": "she", "cn": "Her", "sn": "…", "password": "{SSHA}393aKNBzihkeHWXalkw/vpdy3dYHoh5L"},
{"uid": "he", "cn": "Him", "sn": "…", "password": "{SSHA}393aKNBzihkeHWXalkw/vpdy3dYHoh5L"}
]'

# Linux UID and GID to use for users who do not have their own.
# 65534 = nobody
ldap_virtual_user_uid: 65534
ldap_virtual_user_gid: 65534

# LDAP attributes to assign to users, either Linux users or guests.
# Each entry in the list contains:
# — uid: the login name of the user to modify;
# — attr: the LDAP attribute to set;
# — value: the value to store in the chosen attribute.
# These settings are enforced at each run. Examples:
# — gecos: the full name that typically appears on the login screen;
# — http://directory.fedoraproject.org/docs/389ds/design/shadow-account-support.html.
ldap_users_attrs: '[
{"uid": "you", "attr": "gecos", "value": "Y-O. Udel"},
{"uid": "you", "attr": "shadowLastChange", "value": "16000"},
{"uid": "you", "attr": "shadowMax", "value": "99999"},
{"uid": "you", "attr": "shadowWarning", "value": "7"},
{"uid": "me", "attr": "gecos", "value": "M. Ellen"},
{"uid": "me", "attr": "shadowLastChange", "value": "16000"},
{"uid": "me", "attr": "shadowMax", "value": "99999"},
{"uid": "me", "attr": "shadowWarning", "value": "7"}
]'

# Login name and password of the LibreOffice OnLine web services’ administrator.
# Usefulness not clear; it doesn’t hurt to use the same values as in “nextcloud_admin_user” and “nextcloud_admin_password”…
loolwsd_admin_user: nextcloud_admin
loolwsd_admin_password: nextcloud_admin

# LibreOffice OnLine’s description: “The maximum percentage of system memory consumed
# by all of the LibreOffice Online, after which we start cleaning up idle documents”.
loolwsd_maxmem_asdouble: '80.0'

# Non-system mail aliases (stored in LDAP, in contrast to system aliases, which are stored in /etc/mail/aliases).
# Each entry in the list contains:
# — alias: a unique mail alias, either new or with existing associated recipients;
# — member: the login name of the user to add as a recipient for the alias.
mail_alias_memberships: '[
{"alias": "shop", "member": "you"},
{"alias": "throwable", "member": "me"},
{"alias": "family", "member": "me"},
{"alias": "family", "member": "you"}
]'

# DKIM selector to use (see http://yalis.fr/cms/index.php/post/2014/01/31/Why-buy-a-domain-name-Secure-mail%2E).
# See the “dmz_exim” role for the storage of the private and public keys.
mail_dkim_selector: home

# Actual Linux user, that receives all system emails (for root, postmaster, hostmaster…).
mail_forward_root_to: me

# IPv6 address of the ISP’s smarthost when the ISP does not handle SMTP on IPv6 (example: smtp.bbox.fr).
mail_ignore_ip: '2001:860:e2ef::f503:0:2'

# All local mail destinations, which include managed domains, as well as host names.
mail_local_domains: 'home dmz localhost example.org *.example.org *.local'

# The ISP’s smarthost (which listens on port 25).
mail_smtp_smarthost: smtp.bbox.fr

# The group name for media contents (see also “ldap_system_groups”).
media_group: media

# Custom Minidlna configuration, including the locations where it will look for media contents.
# None of the “media_dir” paths is currently allowed under /opt.
# Apart from “media_dir”, the settings already set upstream must not be overriden.
# See also “nfs_exports”, and https://sourceforge.net/p/minidlna/git/ci/master/tree/minidlna.conf (upstream).
media_minidlna_conf: |
media_dir=V,/srv/nfs/share/video
media_dir=A,/srv/nfs/share/my_CDs
media_dir=A,/srv/nfs/share/my_MP3
media_dir=P,/srv/nfs/share/photos
root_container=B
friendly_name=HomeMedia

# Name of the Movim database in PostgreSQL.
movim_db: movim

# PostgreSQL user who owns the Movim database.
movim_db_user: movim

# Password for the PostgreSQL user who owns the Movim database.
movim_db_password: movim

# Administrator for Movim.
movim_admin_user: movim_admin

# Password of the administrator for Movim.
movim_admin_password: movim_admin

# Localhost port on which Movim is listening
movim_private_port: 33333

# Domain names to which network access from the DMZ is allowed.
# This space-separated list should contain:
# — the web address for checking the current public IP given by the ISP;
# — the web address for updating the dynamic DNS;
# — the web address for updating web applications…
net_allowed_domains: 'checkip.dns.he.net dyn.dns.he.net freedns.afraid.org download.dotclear.org dotaddict.org api.movim.eu'

# Start Of Authority: the root domain name configured on the server.
net_soa: example.org

# Subdomain for the XMPP multi-user chat component.
net_subdom_muc: muc

# Subdomain for the XMPP pub-sub component.
net_subdom_pubsub: pubsub

# Subdomain for which TLS traffic (port 443) is analysed as SSH instead of HTTP.
net_subdom_ssh: ssh

# Local networks from which network connections are trusted.
# OpenSSH requires that the IP in front of the “/” character is the first IP of the range!
net_trusted_ranges: '192.168.1.248/28 127.0.0.0/8 ::1'

# Administrator for Nextcloud (not necessarily an LDAP user).
nextcloud_admin_user: nextcloud_admin

# Password of the administrator for Nextcloud.
nextcloud_admin_password: nextcloud_admin

# Path to Nextcloud’s configuration.
nextcloud_conf: /etc/webapps/nextcloud/config

# Path to local Nextcloud data (not the users’ files).
nextcloud_data: /var/lib/nextcloud

# Name of the Nextcloud database in PostgreSQL.
nextcloud_db: nextcloud

# PostgreSQL user who owns the Nextcloud database.
nextcloud_db_user: nextcloud

# Password for the PostgreSQL user who owns the Nextcloud database.
nextcloud_db_password: nextcloud

# Path to Nextcloud distribution data (not the users’ files).
nextcloud_root: /usr/share/webapps/nextcloud

# System user that will run Nextcloud.
nextcloud_user: cloud

# Local paths (on the safe side of the server) that shall be exported with NFS.
# Each entry contains:
# — name: the name of the NFS export, under /srv/nfs;
# — path: the exported local path.
nfs_exports: '[
{"name": "share", "path": "/mnt/share"},
{"name": "share/video", "path": "/mnt/media/video"},
{"name": "share/my_CDs", "path": "/mnt/media/my_CDs"},
{"name": "share/my_MP3", "path": "/mnt/media/my_MP3"},
{"name": "share/photos", "path": "/mnt/media/photos"}
]'

# NFS export options (https://linux.die.net/man/5/exports).
nfs_options: 'rw,no_subtree_check,no_root_squash,no_wdelay,crossmnt'

# Log level for nginx (http://nginx.org/en/docs/ngx_core_module.html#error_log).
nginx_loglevel: info

# Administrator password for PostgreSQL.
pgpassword: PostgreSQL

# Maximum number of bytes in a Privatebin paste (or image).
privatebin_bytes_limit: 10485760

# Enable discussions in Privatebin (“true” or “false” as a character string).
privatebin_enable_discussion: 'false'

# Enable passwords in Privatebin (“true” or “false” as a character string).
privatebin_enable_passwords: 'false'

# Enable uploads in Privatebin (“true” or “false” as a character string).
privatebin_enable_uploads: 'true'

# Open discussions by default in Privatebin (“true” or “false” as a character string).
privatebin_open_discussion: 'false'

# Delay in seconds before an opportunistic purge of old pastes is attempted while processing a request.
privatebin_purge_delay: 300

# Title for Privatebin in the SSOwat portal.
privatebin_sso_title: Privatebin

# Name of the Prosody database in PostgreSQL.
prosody_db: prosody

# PostgreSQL user who owns the Prosody database.
prosody_db_user: prosody

# Password for the PostgreSQL user who owns the Prosody database.
prosody_db_password: prosody

# Space-separated list of SANE drivers to keep enabled, for scanner sharing.
sane_drivers: epson2

# Space-separated list of pacman mirrors to use.
software_mirrors: 'archlinux.de-labrusse.fr mirror.archlinux.ikoula.com'

# Software that will get removed if present, on next run of the playbook (JSON list).
software_to_del: '["dhcpcd"]'

# Comma-separated list of software that pacman should not automatically upgrade.
software_to_ignore: 'linux,linux-firmware,linux-headers'

# Environment variables that SSH may keep for remote connections.
ssh_accept_env: 'LANG LC_*'

# Allow port-forwarding with SSH (“yes” or “no” as a character string).
ssh_allow_tcpforward: 'yes'

# Allow binding of port-forwardings on the LAN interface with SSH (“yes” or “no” as a character string).
ssh_allow_gatewayports: 'yes'

# Allow X11 forwarding with SSH (“yes” or “no” as a character string).
ssh_allow_x11forward: 'yes'

# Allow SSH tunnels (“yes” or “no” as a character string).
ssh_allow_tunnel: 'yes'

# System user that will accept SSH connections in the DMZ, as a way to get access to the safe zone.
ssh_bastion_user: gatekeeper

# SHA-512 password of the system user who can remotely SSH to the DMZ (here: “let-me-in”).
# See https://unix.stackexchange.com/a/76337 for some help.
ssh_bastion_pwd_sha512: '$6$ZN4I.yIVUj0amxqe$5dBx1d34tNm9NMmmFV3UxZ0V2ecmOjefK5dbTW5Da/xC8M78sZbPQdegcqA3/9Wtr2fMQ0y6pxVh31Q01PrfS/'

# Client-alive interval for the SSH daemon, in seconds.
ssh_clientalive_interval: 600

# Server’s timezone.
timezone: Europe/Paris

# TLS ciphers to enable in TLS-terminating software (HAProxy, Nginx…).
# See https://wiki.mozilla.org/Security/Server_Side_TLS.
tls_ciphers: 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'

# HAProxy server and bind options to use (https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5).
tls_options: 'no-sslv3 no-tls-tickets'

# Transmission (BitTorrent) public/peer port
transmission_bt_port: 60000

# Transmission private RPC port (for the Web UI).
transmission_rpc_port: 50000

# Path to the directory where Transmission should store the downloads that are finished, on the safe side.
transmission_real_done_at: /mnt/share/p2p/iso

# Path to the directory where Transmission should read torrent files to process, on the safe side.
transmission_real_todo_at: /mnt/share/p2p/iso.torrent

# Name given to “transmission_real_done_at” and “transmission_real_todo_at” as NFS exports.
transmission_nfs_done_at: share/p2p/iso
transmission_nfs_todo_at: share/p2p/iso.torrent

# Name of the Wallabag database in PostgreSQL.
wallabag_db: wallabag

# PostgreSQL user who owns the Wallabag database.
wallabag_db_user: wallabag

# Password for the PostgreSQL user who owns the Wallabag database.
wallabag_db_password: wallabag

# Space-separated list of the XMPP accounts that are considered administrators of the XMPP service.
xmpp_admins: 'me@example.org'

# Network hosts from which registration is possible (else it is forbidden).
# Registration of hosted users is automatic.
xmpp_registration_hosts: '127.0.0.1 192.168.1.254 192.168.1.253 192.168.1.252'

# Secret value known to the XMPP upload service (HTTP), so that it is only used by the XMPP network.
xmpp_upload_secret: 'xmpp upload secret'

+ 8
- 0
group_vars/back View File

@@ -0,0 +1,8 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

hostname: home
ssh_allowed_users: 'root jane john'
software_to_add: '["intel-ucode"]'

+ 8
- 0
group_vars/front View File

@@ -0,0 +1,8 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

hostname: dmz
ssh_allowed_users: 'root {{ssh_bastion_user}}'
software_to_add: '[]'

+ 9
- 0
group_vars/front_chroot View File

@@ -0,0 +1,9 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

hostname: dmz
chroot: "/var/lib/machines/{{DMZ}}"
ssh_allowed_users: 'root {{ssh_bastion_user}}'
software_to_add: '[]'

+ 9
- 0
production View File

@@ -0,0 +1,9 @@
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

[back]
ansible.home

[front]
ansible.dmz

+ 6
- 0
roles/_maintenance_start/defaults/main.yml View File

@@ -0,0 +1,6 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

ansible_python_interpreter: /usr/bin/python2

+ 25
- 0
roles/_maintenance_start/tasks/main.yml View File

@@ -0,0 +1,25 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

- name: stop some services
shell: |
for u in \
nextcloud-maintenance.{timer,service} uwsgi@nextcloud.{socket,service} \
dehydrated.{timer,service} \
minidlna.service \
nfs-server.service
do
systemctl stop $u
done
when:
- (inventory_hostname in groups['back'])

- name: stop some services
shell: |
for u in spamassassin.service spamassassin-update.{timer,service}; do
systemctl stop $u
done
when:
- (inventory_hostname in groups['front'])

+ 6
- 0
roles/_maintenance_stop/defaults/main.yml View File

@@ -0,0 +1,6 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

ansible_python_interpreter: /usr/bin/python2

+ 27
- 0
roles/_maintenance_stop/tasks/main.yml View File

@@ -0,0 +1,27 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

- name: stop again services that may got started by handlers
include_role: name=_maintenance_start allow_duplicates=true

- name: restart some services
shell: |
for u in \
nextcloud-maintenance.timer uwsgi@nextcloud.socket \
dehydrated.timer \
minidlna.service \
nfs-server.service
do
systemctl start $u
done
when:
- (inventory_hostname in groups['back'])

- name: restart some services
shell: |
systemctl start spamassassin.service
systemctl start spamassassin-update.timer
when:
- (inventory_hostname in groups['front'])

+ 6
- 0
roles/acme_back/defaults/main.yml View File

@@ -0,0 +1,6 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

ansible_python_interpreter: /usr/bin/python2

+ 12
- 0
roles/acme_back/files/dehydrated.timer View File

@@ -0,0 +1,12 @@
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

[Unit]
Description=Run Dehydrated (Let’s Encrypt client) every week

[Timer]
OnCalendar=weekly

[Install]
WantedBy=timers.target

+ 10
- 0
roles/acme_back/handlers/main.yml View File

@@ -0,0 +1,10 @@
---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.

- name: restart dehydrated.service
systemd:
daemon_reloa