├── .ansible-lint ├── .yamllint ├── LICENSE ├── README.md ├── defaults └── main.yml ├── files └── ssh_config ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── instance.yml └── main.yml └── templates ├── Dockerfile.j2 ├── backup.yaml.j2 ├── docker-compose.yaml.j2 ├── fetch_repos ├── fetch_repos_addons ├── odoo.conf.j2 ├── post_restore-odootest.sql.j2 ├── pre_restore-odootest.sql.j2 ├── pull_remote_files.sh.j2 ├── repos-addons.yaml.j2 ├── repos.yaml.j2 ├── restore-odootest.yaml.j2 └── whitelists.yaml.j2 /.ansible-lint: -------------------------------------------------------------------------------- 1 | --- 2 | warn_list: # or 'skip_list' to silence them completely 3 | - git-latest # Git checkouts must contain explicit version 4 | - ignore-errors # Use failed_when and specify error conditions instead of using ignore_errors 5 | - no-changed-when # Commands should not change things if nothing needs doing 6 | - no-handler # Tasks that run when changed should likely be handlers 7 | - package-latest # Package installs should not use latest 8 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | # Based on ansible-lint config 3 | extends: default 4 | 5 | rules: 6 | braces: 7 | max-spaces-inside: 1 8 | level: error 9 | brackets: 10 | max-spaces-inside: 1 11 | level: error 12 | colons: 13 | max-spaces-after: -1 14 | level: error 15 | commas: 16 | max-spaces-after: -1 17 | level: error 18 | # comments enable 19 | comments: enable 20 | comments-indentation: enable 21 | document-start: enable 22 | empty-lines: 23 | max: 3 24 | level: error 25 | hyphens: 26 | level: error 27 | indentation: 28 | level: warning 29 | indent-sequences: consistent 30 | spaces: 4 31 | check-multi-line-strings: true 32 | key-duplicates: enable 33 | line-length: disable 34 | new-line-at-end-of-file: enable 35 | new-lines: 36 | type: unix 37 | # trailing-spaces enable 38 | trailing-spaces: enable 39 | truthy: enable 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | 3 | Version 3, 19 November 2007 4 | 5 | Copyright © 2007 Free Software Foundation, Inc. 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. 13 | 14 | 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. 15 | 16 | Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. 17 | 18 | A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. 19 | 20 | The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. 21 | 22 | An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. 23 | 24 | The precise terms and conditions for copying, distribution and modification follow. 25 | 26 | TERMS AND CONDITIONS 27 | 28 | 0. Definitions. 29 | 30 | "This License" refers to version 3 of the GNU Affero General Public License. 31 | 32 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 33 | 34 | "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. 35 | 36 | 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. 37 | 38 | A "covered work" means either the unmodified Program or a work based on the Program. 39 | 40 | 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. 41 | 42 | 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. 43 | 44 | 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. 45 | 46 | 1. Source Code. 47 | 48 | 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. 49 | 50 | 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. 51 | 52 | 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. 53 | 54 | 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. 55 | 56 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 57 | 58 | The Corresponding Source for a work in source code form is that same work. 59 | 60 | 2. Basic Permissions. 61 | 62 | 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. 63 | 64 | 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. 65 | 66 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 67 | 68 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 69 | 70 | 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. 71 | 72 | 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. 73 | 74 | 4. Conveying Verbatim Copies. 75 | 76 | 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. 77 | 78 | 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. 79 | 80 | 5. Conveying Modified Source Versions. 81 | 82 | 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: 83 | 84 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 85 | 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". 86 | 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. 87 | 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. 88 | 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. 89 | 90 | 6. Conveying Non-Source Forms. 91 | 92 | 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: 93 | 94 | 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. 95 | 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. 96 | 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. 97 | 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. 98 | 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. 99 | 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. 100 | 101 | 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. 102 | 103 | "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. 104 | 105 | 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). 106 | 107 | 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. 108 | 109 | 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. 110 | 111 | 7. Additional Terms. 112 | 113 | "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. 114 | 115 | 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. 116 | 117 | 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: 118 | 119 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 120 | 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 121 | 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 122 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 123 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 124 | 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. 125 | 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. 126 | 127 | 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. 128 | 129 | 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. 130 | 131 | 8. Termination. 132 | 133 | 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). 134 | 135 | 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. 136 | 137 | 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. 138 | 139 | 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. 140 | 141 | 9. Acceptance Not Required for Having Copies. 142 | 143 | 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. 144 | 145 | 10. Automatic Licensing of Downstream Recipients. 146 | 147 | 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. 148 | 149 | 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. 150 | 151 | 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. 152 | 153 | 11. Patents. 154 | 155 | 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". 156 | 157 | 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. 158 | 159 | 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. 160 | 161 | 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. 162 | 163 | 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. 164 | 165 | 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. 166 | 167 | 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. 168 | 169 | 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. 170 | 171 | 12. No Surrender of Others' Freedom. 172 | 173 | 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. 174 | 175 | 13. Remote Network Interaction; Use with the GNU General Public License. 176 | 177 | Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. 178 | 179 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 180 | 181 | 14. Revised Versions of this License. 182 | 183 | The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 184 | 185 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. 186 | 187 | If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 188 | 189 | 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. 190 | 191 | 15. Disclaimer of Warranty. 192 | 193 | 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. 194 | 195 | 16. Limitation of Liability. 196 | 197 | 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. 198 | 199 | 17. Interpretation of Sections 15 and 16. 200 | 201 | 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. 202 | 203 | END OF TERMS AND CONDITIONS 204 | 205 | How to Apply These Terms to Your New Programs 206 | 207 | 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. 208 | 209 | 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. 210 | 211 | 212 | Copyright (C) 213 | 214 | This program is free software: you can redistribute it and/or modify 215 | it under the terms of the GNU Affero General Public License as 216 | published by the Free Software Foundation, either version 3 of the 217 | License, or (at your option) any later version. 218 | 219 | This program is distributed in the hope that it will be useful, 220 | but WITHOUT ANY WARRANTY; without even the implied warranty of 221 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 222 | GNU Affero General Public License for more details. 223 | 224 | You should have received a copy of the GNU Affero General Public License 225 | along with this program. If not, see . 226 | Also add information on how to contact you by electronic and paper mail. 227 | 228 | If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. 229 | 230 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker_odoo 2 | =========== 3 | 4 | This role deploys Odoo (community edition) in a Docker, together with PostgreSQL, postfix proxy, metabase, etc. as needed 5 | By default, this role would deploy as many instances as defined in odoo_instances variable. 6 | Usually we deploy for each of our customers 2 instance (prod and test) with the following workflow : 7 | 1. Build Odoo image on test instance 8 | 2. Test image on test instance 9 | 3. Once confirmed OK, copy test image in prod image and restart prod instance on this new image 10 | 4. Use prod image on production instance 11 | 12 | This role is originally derivated from the work done by [Tecnativa/Doodba](https://github.com/Tecnativa/doodba) for creating a generic Odoo Docker, although it has been reworked lately in order to reduce drastically the size of the Docker image used, since using Tecnativa Doodba, we were reaching 1.5 GB for the image, when the new images are around 1 GB. 13 | 14 | This role is taking advantage of [Le Filament Odoo Docker image](https://hub.docker.com/repository/docker/lefilament/odoo) which is also described on (and built from) [Le Filament GitLab page](https://sources.le-filament.com/lefilament/odoo_docker) and adds on top additional OCA modules and private modules that are used by most of our customers. 15 | 16 | 17 | Requirements 18 | ------------ 19 | 20 | None 21 | 22 | Role Variables 23 | -------------- 24 | 25 | This role makes use of an important number of variables. 26 | Part of these variables are described with comments in defaults/main.yml. 27 | 28 | The variable structure for instances is defined below : 29 | ```yaml 30 | # You can define as many non prod instances as you want 31 | # You can also deploy only prod instance or only test instances on one server, 32 | # in that case, you would need to uncomment the OPTIONAL variables below 33 | # By default, an Odoo server is deployed with both prod and test instances. 34 | # By default, all variables for test instance are copied from prod one, but URL and database name 35 | 36 | # Odoo instances definition. 37 | odoo_instances: 38 | # Production instance 39 | odoo: 40 | # Name of a production instance. Itself if it's a production instance (like here). 41 | prod_instance: odoo 42 | # Name of an instance from which take image (like here). Itself if image build is done on this instance. 43 | image_instance: odootest 44 | # Name of an instance from which take backups. Itself if backups are made for this instance (like here). 45 | backup_instance: odoo 46 | ## URL (only sub.domain without https:// in front) 47 | url: "{{ SERVER_odoo_url }}" 48 | master_pass: "{{ SERVER_odoo_master_pass }}" 49 | ## Database identifiers user and password 50 | db_user: "{{ SERVER_odoo_db_user }}" 51 | db_pass: "{{ SERVER_odoo_db_pass }}" 52 | ## Database name 53 | db: "{{ SERVER_odoo_db_name }}" 54 | ## OPTIONAL - For maintenance only - Backup password 55 | # odoo_backup_pass: "{{ SERVER_odoo_backup_pass }}" 56 | 57 | # Test instance 58 | odootest: 59 | # This test instance rely on previous production instance. 60 | prod_instance: odoo 61 | # This instance build it's image. 62 | image_instance: odootest 63 | # This instance need to restore backups from production instance. 64 | backup_instance: odoo 65 | ## URL (only sub.domain without https:// in front) 66 | url: "{{ SERVER_odoo_test_url }}" 67 | ## Database Name 68 | db: "{{ SERVER_odoo_db_name_test }}" 69 | ## Custom modules Le Filament (one module per repo and specify branch if differ from default odoo version) 70 | # custom_modules: 71 | # - repo: lefilament_account 72 | # - repo: lefilament_export_journal 73 | # branch: "14.0" 74 | ## OCA modules - these should be limited to the ones not already defined 75 | ## in groups_vars/docker_odoo in default_odoo_custom_modules_oca (since these 76 | ## are already part of lefilament/odoo:10.0 and 12.0 dockers) 77 | # custom_modules_oca: 78 | # - repo: server-tools 79 | # modules: 80 | # - auto_backup 81 | ## Other Odoo modules where git repo is the module 82 | # other_repos: 83 | # - repo: filament 84 | # url: git@github.com:lefilament/link_sale_project_tasks.git 85 | ## Other Odoo modules where git repo contains various modules 86 | # other_modules: 87 | # - repo: filament 88 | # url: https://github.com/lefilament/bank-statement-import.git 89 | # branch: 12.0-mig-account_bank_statement_import_ofx 90 | # modules: 91 | # - account_bank_statement_import_ofx 92 | ## OPTIONAL - Extra pip packages to be installed in image 93 | # odoo_pip_packages: unidecode 94 | ## OPTIONAL - Odoo multilingual - Will install Odoo with all languages (English and French only if set to no - by default) - uncomment and set to yes if needed 95 | # odoo_multilingual: false 96 | ## OPTIONAL - Force usage of Python 3.6 for Odoo 12.0 97 | # odoo_python36: false 98 | 99 | ### OPTIONAL - Mail server configuration - for Odoo - uncomment to add mail server 100 | ## Mail domain 101 | # mailname: "{{ SERVER_mail_domain }}" 102 | ## Mail server 103 | # mailserver: "{{ SERVER_mail_srv_url }}" 104 | ## SMTP port 105 | # smtpport: 465 106 | ## SMTP user 107 | # smtpuser: "{{ SERVER_mail_odoo_user }}" 108 | ## SMTP password 109 | # smtppass: "{{ SERVER_mail_odoo_pass }}" 110 | 111 | ## OPTIONAL - GIT private keys - for retrieving private repos (outside Le Filament ones) - uncomment and provide keys as needed 112 | # git_private_keys: "{{ SERVER_git_private_keys }}" 113 | 114 | ## OPTIONAL - Whitelisted URLs allowed to be reached from Odoo SERVER 115 | # whitelisted_urls: 116 | # - github.com 117 | # - sources.le-filament.com 118 | ``` 119 | 120 | * Extra modules : although Odoo comes with a number of apps, the real added value comes from community modules. A number of variables allow to retrieve modules from various sources : 121 | * git_modules_privkey : private key used to retrieve modules from private repos (for now only supports ed25519) 122 | * custom_modules : allows to retrieve unitary modules from custom_modules_base_url variable. It's possible to specify the git branch to use (with `branch: `), else the same branch than odoo version for the current instance will be used. This is useful if like Le Filament you are developping a number of modules, this way you only have to define path to the modules, and not the full URL each time 123 | * custom_modules_oca: this allows to retrieve named modules from OCA repositories (https://github.com/OCA) 124 | * other_repos : this allows to retrieve modules from a git repository (each repository is a single module) 125 | * other_modules : this allows to retrieve named modules from git repositories (each repo containing multiple modules) 126 | 127 | * Internet Access : by default, the dockers deployed by this role do not have access to Internet (meaning they will not be able to communicate towards the Internet, nor be accessible from the Internet). This is done by creating only internal networks. The following variables allow to either deactivate this isolation, or to whitelists URL that would be accessible from the Odoo Docker instance using [Tecnativa Whitelist Docker](https://github.com/Tecnativa/docker-whitelist) : 128 | * restrict_internet_access : by setting this variable to true, all deployed Docker will be allowed to initiate connections towards the Internet 129 | * whitelisted_urls : this list may contain URLs that would be accessible from prod and nonprod Odoo instances 130 | * extra_urls defined in either odoo_prod or any odoo_nonprod_instances may contain URLs that would be accessible only from the instance in which it is defined (as an example, with this variable you would be able to allow access to some API only for prod instance) 131 | 132 | * Mail server : by default, nonprod instances are not allowed to communicate towards mail server and are connected to a [mailhog](https://github.com/mailhog/MailHog) instance allowing to check what e-mails would have been sent out. This would allow again to have only prod instance being able to send e-mails to partners. The following variables can be used to authorize access to mail server (SMTP/IMAP) and to configure local postfix relay (this way you would not need to configure e-mail server credentials in Odoo database) : 133 | * mailname : if defined (together with the mailserver and smtp** variables) a postfix local relay will be deployed and used by prod instance only. If not defined, a mailhog instance would be deployed on prod also. 134 | * imap_mailserver : if defined a whitelist is created to allow connecting to IMAP server on port 993 (see also the previous section related to Internet Access for explaining why these whitelists might be required) 135 | 136 | * Backups (for backups to be deployed, host needs to be in maintenance_contract group) : the backups make use of [Tecnativa Duplicity Docker](https://github.com/Tecnativa/docker-duplicity) 137 | * swift_accounts dict parameters for object storage instances where backups should be pushed daily 138 | * odoo_backup_pass : Passphrase for encryption of backups 139 | 140 | * Metabase : This role allows for deployment of [Metabase](https://www.metabase.com/), a Business Intelligence (BI) Open Source tool that would be connected with readonly used on prod database in order to extract metrics and indicators from Odoo database and display those in dashboards. 141 | 142 | 143 | Dependencies 144 | ------------ 145 | 146 | This role requires the following Ansible collection : 147 | * community.docker 148 | 149 | This Docker role supposes that Traefik is deployed as an inverseproxy in front of the deployed Dockers. 150 | The following role is used by Le Filament for deploying Traefik : docker_server (https://sources.le-filament.com/lefilament/ansible-roles/docker_server) 151 | 152 | Example Playbook 153 | ---------------- 154 | 155 | Given the number of variables (see defaults/main.yml), it would be preferable to create a host_vars file listing all the variables needed for you Odoo server, rather than giving your variables through the playbook directly. 156 | 157 | 158 | License 159 | ------- 160 | 161 | AGPL-3 162 | 163 | Author Information 164 | ------------------ 165 | 166 | Le Filament (https://le-filament.com) 167 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ## Odoo configuration 3 | odoo_setup_version: 16 4 | 5 | ## Custom modules default URL for retrieving custom modules : 6 | custom_modules_base_url: "https://sources.le-filament.com/lefilament" 7 | 8 | ## OPTIONAL - Default configuration to use namespaces (set to false to not use namespace) 9 | docker_userns_remap: true 10 | 11 | # whether dockers should be granted access to Internet or if networks are internal only 12 | # (defaults to true meaning docker containers have no direct internet access, 13 | # whitelisted URLs should be used to grant specific access) 14 | restrict_internet_access: true 15 | 16 | ## OPTIONAL - Allow access to Odoo DB from outside world 17 | odoo_remote_db_access: false 18 | -------------------------------------------------------------------------------- /files/ssh_config: -------------------------------------------------------------------------------- 1 | Host sources.le-filament.com 2 | IdentityFile ~root/.ssh/id_ed25519.sources 3 | IdentitiesOnly yes 4 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Start odoo whitelists 3 | community.docker.docker_compose: 4 | project_src: /home/docker 5 | files: whitelists.yaml 6 | project_name: whitelists 7 | 8 | - name: Pull odoo ML image 9 | community.docker.docker_image: 10 | name: lefilament/odoo:{{ instance_odoo_version }}_ml 11 | source: pull 12 | force_source: true 13 | when: not ansible_check_mode and instance.value.odoo_multilingual | default(false) 14 | 15 | - name: Pull odoo Python3.6 image 16 | community.docker.docker_image: 17 | name: lefilament/odoo:{{ instance_odoo_version }}_py3.6 18 | source: pull 19 | force_source: true 20 | when: not ansible_check_mode and instance.value.odoo_python36 | default(false) 21 | 22 | - name: Pull odoo image 23 | community.docker.docker_image: 24 | name: lefilament/odoo:{{ instance_odoo_version }} 25 | source: pull 26 | force_source: true 27 | when: not ansible_check_mode and not (instance.value.odoo_multilingual | default(false) or instance.value.odoo_python36 | default(false)) 28 | 29 | - name: Build odoo image 30 | community.docker.docker_compose: 31 | project_src: /home/docker/{{ instance.key }}/ 32 | build: true 33 | nocache: true 34 | recreate: always 35 | restarted: true 36 | remove_orphans: true 37 | async: 600 38 | poll: 10 39 | when: not ansible_check_mode 40 | 41 | - name: Start odoo container 42 | community.docker.docker_compose: 43 | project_src: /home/docker/{{ instance.key }}/ 44 | remove_orphans: true 45 | when: not ansible_check_mode 46 | 47 | - name: Remove intermediate image 48 | community.docker.docker_prune: 49 | builder_cache: true 50 | images: true 51 | images_filters: 52 | label: stage=builder 53 | when: not ansible_check_mode and inventory_hostname not in groups['maintenance_contract'] 54 | 55 | - name: Remove ssh private keys 56 | ansible.builtin.file: 57 | path: "/home/docker/{{ instance.key }}/odoo/id_ed25519.sources" 58 | state: absent 59 | when: not ansible_check_mode and inventory_hostname not in groups['maintenance_contract'] 60 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: lefilament 4 | description: Role for deploying Odoo Community Edition on Docker 5 | company: Le Filament (https://le-filament.com) 6 | license: AGPL-3.0-or-later 7 | min_ansible_version: "2.1" 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - bionic 12 | - focal 13 | galaxy_tags: 14 | - odoo 15 | - community 16 | - docker 17 | - metabase 18 | - postgresql 19 | -------------------------------------------------------------------------------- /tasks/instance.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Create Odoo docker structure on server in /home/docker/{{ item.key }} 3 | ansible.builtin.file: 4 | name: "/home/docker/{{ item.key }}" 5 | state: directory 6 | owner: root 7 | group: root 8 | mode: '0755' 9 | 10 | - name: Container building requirements 11 | when: item.value.image_instance | default(false) == item.key 12 | tags: ['never', 'build_odoo'] 13 | block: 14 | - name: Create Odoo private docker structure on server in /home/docker/{{ item.key }} 15 | ansible.builtin.file: 16 | name: "/home/docker/{{ item.key }}/odoo/private" 17 | state: directory 18 | owner: root 19 | group: root 20 | mode: '0755' 21 | 22 | - name: Copy update scripts to be run during build 23 | ansible.builtin.template: 24 | src: "{{ file }}" 25 | dest: "/home/docker/{{ item.key }}/odoo/private/" 26 | owner: root 27 | group: root 28 | mode: '0750' 29 | with_items: 30 | - fetch_repos 31 | - fetch_repos_addons 32 | loop_control: 33 | loop_var: file 34 | notify: 35 | - Pull odoo ML image 36 | - Pull odoo Python3.6 image 37 | - Pull odoo image 38 | - Build odoo image 39 | 40 | - name: Set repos variables from template 41 | ansible.builtin.template: 42 | src: "{{ file }}.j2" 43 | dest: "/home/docker/{{ item.key }}/odoo/private/{{ file }}" 44 | owner: root 45 | group: root 46 | mode: '0644' 47 | with_items: 48 | - "repos.yaml" 49 | - "repos-addons.yaml" 50 | loop_control: 51 | loop_var: file 52 | notify: 53 | - Pull odoo ML image 54 | - Pull odoo Python3.6 image 55 | - Pull odoo image 56 | - Build odoo image 57 | 58 | - name: Copy odoo.conf file 59 | ansible.builtin.template: 60 | src: odoo.conf.j2 61 | dest: "/home/docker/{{ item.key }}/odoo/odoo.conf" 62 | owner: root 63 | group: root 64 | mode: '0600' 65 | notify: Build odoo image 66 | 67 | - name: Copy private GitLab ssh keys file 68 | ansible.builtin.copy: 69 | content: "{{ git_modules_privkey | default('') }}" 70 | dest: "/home/docker/{{ item.key }}/odoo/id_ed25519.sources" 71 | owner: root 72 | group: root 73 | mode: '0400' 74 | notify: 75 | - Build odoo image 76 | - Remove ssh private keys 77 | - Remove intermediate image 78 | 79 | - name: Copy ssh config for connecting to LF Gitlab 80 | ansible.builtin.copy: 81 | src: ssh_config 82 | dest: "/home/docker/{{ item.key }}/odoo/ssh_config" 83 | owner: root 84 | group: root 85 | mode: '0444' 86 | notify: Build odoo image 87 | 88 | - name: Copy private Git ssh keys file 89 | when: git_private_keys | default(false) 90 | ansible.builtin.copy: 91 | content: "{{ git_private_keys }}" 92 | dest: "/home/docker/{{ item.key }}/odoo/id_rsa" 93 | owner: root 94 | group: root 95 | mode: '0400' 96 | notify: Build odoo image 97 | 98 | - name: Copy Dockerfile to retrieve private repos and extra OCA ones 99 | ansible.builtin.template: 100 | src: Dockerfile.j2 101 | dest: "/home/docker/{{ item.key }}/odoo/Dockerfile" 102 | owner: root 103 | group: root 104 | mode: '0644' 105 | notify: 106 | - Pull odoo ML image 107 | - Pull odoo Python3.6 image 108 | - Pull odoo image 109 | - Build odoo image 110 | 111 | - name: Get image from another instance 112 | when: item.value.image_instance | default(false) != item.key 113 | block: 114 | - name: Check if instance image exists 115 | community.docker.docker_image_info: 116 | name: "filament/{{ item.key }}:{{ instance_odoo_setup.odoo_version }}" 117 | register: prod_image 118 | 119 | - name: Copy image from image_instance if it does not exist 120 | when: prod_image.images | length == 0 121 | community.docker.docker_image: 122 | name: "filament/{{ item.value.image_instance }}:{{ instance_odoo_setup.odoo_version }}" 123 | repository: "filament/{{ item.key }}:{{ instance_odoo_setup.odoo_version }}" 124 | source: local 125 | 126 | - name: Copy docker compose service 127 | ansible.builtin.template: 128 | src: docker-compose.yaml.j2 129 | dest: "/home/docker/{{ item.key }}/docker-compose.yml" 130 | owner: root 131 | group: root 132 | mode: '0400' 133 | notify: Start odoo container 134 | 135 | # -------------------------------------------------- 136 | # non-prod restore section 137 | # -------------------------------------------------- 138 | - name: Restore backups from another instance 139 | when: (item.value.backup_instance | default(item.key) != item.key or item.value.backup_host | default(inventory_hostname) != inventory_hostname) and inventory_hostname in groups.maintenance_contract 140 | tags: 'backup_odoo' 141 | block: 142 | - name: Copy sql script to be run before restoring db from backup_instance 143 | ansible.builtin.template: 144 | src: pre_restore-odootest.sql.j2 145 | dest: "/home/docker/backups/pre_restore-{{ item.key }}.sql" 146 | owner: root 147 | group: root 148 | mode: '0444' 149 | 150 | - name: Copy sql script to be run after restoring db from backup_instance 151 | ansible.builtin.template: 152 | src: post_restore-odootest.sql.j2 153 | dest: "/home/docker/backups/post_restore-{{ item.key }}.sql" 154 | owner: root 155 | group: root 156 | mode: '0444' 157 | 158 | - name: Copy compose file to restore db from backup_instance 159 | ansible.builtin.template: 160 | src: restore-odootest.yaml.j2 161 | dest: "/home/docker/backups/restore-{{ item.key }}{{ account_index + 1 }}.yaml" 162 | owner: root 163 | group: root 164 | mode: '0400' 165 | loop: "{{ swift_accounts }}" 166 | loop_control: 167 | label: "account {{ account_index + 1 }}" 168 | index_var: account_index 169 | loop_var: account 170 | 171 | # -------------------------------------------------- 172 | # prod backup section 173 | # -------------------------------------------------- 174 | - name: Backup 175 | when: item.value.backup_instance | default(false) == item.key and item.value.backup_host | default(inventory_hostname) == inventory_hostname and inventory_hostname in groups.maintenance_contract 176 | tags: 'backup_odoo' 177 | block: 178 | - name: "Copy docker compose for backup account {{ account_index + 1 }}" 179 | ansible.builtin.template: 180 | src: backup.yaml.j2 181 | dest: "/home/docker/backups/backup-{{ item.key }}{{ account_index + 1 }}.yaml" 182 | owner: root 183 | group: root 184 | mode: '0400' 185 | loop: "{{ swift_accounts }}" 186 | loop_control: 187 | label: "account {{ account_index + 1 }}" 188 | index_var: account_index 189 | loop_var: account 190 | 191 | # TODO: duplicate with swift_accounts 192 | - name: "Add cron job to run every day backup account {{ account_index + 1 }}" 193 | ansible.builtin.cron: 194 | name: "backup {{ item.key }}{{ account_index + 1 }}" 195 | minute: "{{ '%H' | strftime((('1970-01-01 ' + backup_time_start) | to_datetime).timestamp() + (swift_accounts | length - (account_index + 1)) * ((backup_time_slot_duration | community.general.to_seconds - swift_accounts | length * backup_time_max_duration | community.general.to_seconds) / (swift_accounts | length - 1) + backup_time_max_duration | community.general.to_seconds) | int) }}" 196 | hour: "{{ '%H' | strftime((('1970-01-01 ' + backup_time_start) | to_datetime).timestamp() + (swift_accounts | length - (account_index + 1)) * ((backup_time_slot_duration | community.general.to_seconds - swift_accounts | length * backup_time_max_duration | community.general.to_seconds) / (swift_accounts | length - 1) + backup_time_max_duration | community.general.to_seconds) | int) }}" 197 | job: "/usr/bin/docker-compose -f /home/docker/backups/backup-{{ item.key }}{{ account_index + 1 }}.yaml run --rm backup_odoo" 198 | loop: "{{ swift_accounts }}" 199 | loop_control: 200 | label: "account {{ account_index + 1 }}" 201 | index_var: account_index 202 | loop_var: account 203 | 204 | # Flush handlers. 205 | - name: Set facts 206 | ansible.builtin.set_fact: 207 | instance: "{{ {'key': item.key, 'value': item.value} }}" 208 | instance_odoo_version: "{{ instance_odoo_setup.odoo_version }}" 209 | cacheable: false 210 | 211 | - name: Flush handlers 212 | ansible.builtin.meta: flush_handlers 213 | 214 | # -------------------------------------------------- 215 | # Postgres Readonly user 216 | # -------------------------------------------------- 217 | - name: Postgres Read-only user 218 | when: item.value.odoo_remote_db_access | default(false) 219 | block: 220 | - name: Allow readonly user connection to prod db (with userns_remap) 221 | when: docker_userns_remap 222 | ansible.builtin.blockinfile: 223 | path: "/var/lib/docker/{{ dockremap_subuid }}.{{ dockremap_subgid }}/volumes/{{ item.key }}_db/_data/pg_hba.conf" 224 | block: | 225 | host {{ item.value.db }} {{ odoo_instances[item.value.prod_instance | default(item.key)].db_user }} 172.16.0.0/12 md5 226 | host postgres {{ odoo_instances[item.value.prod_instance | default(item.key)].db_user }} 172.16.0.0/12 md5 227 | host {{ item.value.db }} {{ item.value.odoo_db_rouser }} all md5 228 | 229 | - name: PROD Allow readonly user connection to prod db (no userns_remap) 230 | when: not docker_userns_remap 231 | ansible.builtin.blockinfile: 232 | path: /var/lib/docker/volumes/{{ item.key }}_db/_data/pg_hba.conf 233 | block: | 234 | host {{ item.value.db }} {{ odoo_instances[item.value.prod_instance | default(item.key)].db_user }} 172.16.0.0/12 md5 235 | host postgres {{ odoo_instances[item.value.prod_instance | default(item.key)].db_user }} 172.16.0.0/12 md5 236 | host {{ item.value.db }} {{ item.value.odoo_db_rouser }} all md5 237 | 238 | - name: PROD Disable access all rights (with userns_remap) 239 | when: docker_userns_remap 240 | ansible.builtin.lineinfile: 241 | name: "/var/lib/docker/{{ dockremap_subuid }}.{{ dockremap_subgid }}/volumes/{{ item.key }}_db/_data/pg_hba.conf" 242 | regexp: "^host all all all md5" 243 | line: "#host all all all md5" 244 | 245 | - name: PROD Disable access all rights (no userns_remap) 246 | when: not docker_userns_remap 247 | ansible.builtin.lineinfile: 248 | name: /var/lib/docker/volumes/{{ item.key }}_db/_data/pg_hba.conf 249 | regexp: "^host all all all md5" 250 | line: "#host all all all md5" 251 | 252 | # TODO: add restart db container 253 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # -------------------------------------------------- 3 | # Whitelists section 4 | # -------------------------------------------------- 5 | 6 | - name: Copy docker compose for whitelists 7 | ansible.builtin.template: 8 | src: whitelists.yaml.j2 9 | dest: "/home/docker/whitelists.yaml" 10 | owner: root 11 | group: root 12 | mode: '0400' 13 | notify: Start odoo whitelists 14 | when: restrict_internet_access and whitelisted_urls | default([]) 15 | 16 | - name: NON-PROD instance setup 17 | ansible.builtin.include_tasks: 18 | file: instance.yml 19 | apply: 20 | tags: backup_odoo 21 | with_dict: "{{ odoo_instances }}" 22 | loop_control: 23 | label: "{{ item.key }}" 24 | vars: 25 | instance_odoo_setup: "{{ odoo_setup_conf[item.value.odoo_setup_version | default(odoo_setup_version)] }}" 26 | when: not (item.value.prod_instance | default(false) == item.key) and (odoo_instance is undefined or item.key == odoo_instance) 27 | 28 | - name: PROD instance setup 29 | ansible.builtin.include_tasks: 30 | file: instance.yml 31 | apply: 32 | tags: backup_odoo 33 | with_dict: "{{ odoo_instances }}" 34 | loop_control: 35 | label: "{{ item.key }}" 36 | vars: 37 | instance_odoo_setup: "{{ odoo_setup_conf[item.value.odoo_setup_version | default(odoo_setup_version)] }}" 38 | when: item.value.prod_instance | default(false) == item.key and (odoo_instance is undefined or item.key == odoo_instance) 39 | 40 | # -------------------------------------------------- 41 | # Remote imports section 42 | # -------------------------------------------------- 43 | - name: Remote Imports 44 | block: 45 | - name: Push private keys for any external tool connection 46 | when: private_keys is defined 47 | ansible.builtin.copy: 48 | content: "{{ private_keys }}" 49 | dest: "/root/.ssh/id_rsa" 50 | owner: root 51 | group: root 52 | mode: '0400' 53 | 54 | - name: PROD Copy script file for collecting remote files 55 | when: private_pull is defined 56 | ansible.builtin.template: 57 | src: pull_remote_files.sh.j2 58 | dest: /root/pull_remote_files.sh 59 | owner: root 60 | group: root 61 | mode: '0700' 62 | 63 | - name: PROD add cron job to pull files from remote server 64 | when: private_pull is defined 65 | ansible.builtin.cron: 66 | name: pull remote server files 67 | minute: "30" 68 | hour: "23" 69 | job: /root/pull_remote_files.sh 70 | -------------------------------------------------------------------------------- /templates/Dockerfile.j2: -------------------------------------------------------------------------------- 1 | ## Image to get git repos 2 | {# TODO: make base image a variable #} 3 | FROM lefilament/odoo:{{ instance_odoo_setup.odoo_version }}{% if item.value.odoo_python36 | default(false) %}_py3.6{% endif %}{% if item.value.odoo_multilingual | default(false) %}_ml{% endif %} as odoo_addons 4 | LABEL stage=builder 5 | USER root 6 | # Install GitLab private keys 7 | COPY ./id_ed25519.sources /root/.ssh/ 8 | COPY ./ssh_config /root/.ssh/config 9 | {% if git_private_keys is defined %} 10 | # Install private keys 11 | COPY ./id_rsa /root/.ssh/ 12 | {% endif %} 13 | # Install private repos 14 | COPY ./private/* /opt/odoo/private/ 15 | RUN chown -R root:root /opt/odoo/additional_addons /opt/odoo/private_addons 16 | RUN /opt/odoo/private/fetch_repos_addons 17 | RUN /opt/odoo/private/fetch_repos 18 | 19 | ## Final image 20 | {# TODO: make base image a variable #} 21 | FROM lefilament/odoo:{{ instance_odoo_setup.odoo_version }}{% if item.value.odoo_python36 | default(false) %}_py3.6{% endif %}{% if item.value.odoo_multilingual | default(false) %}_ml{% endif %} as final 22 | USER root 23 | COPY --from=odoo_addons --chown=odoo:odoo /opt/odoo/private_addons /opt/odoo/private_addons 24 | COPY --from=odoo_addons --chown=odoo:odoo /opt/odoo/additional_addons /opt/odoo/additional_addons 25 | {% if item.value.odoo_pip_packages is defined %} 26 | # Install pip packages 27 | RUN pip install {{ item.value.odoo_pip_packages }} 28 | {% endif %} 29 | {{ item.value.odoo_specific_dockerfile_commands | default("") }} 30 | # Copy Odoo configuration file 31 | COPY --chown=odoo:odoo ./odoo.conf /opt/odoo/etc/odoo.conf 32 | USER odoo 33 | -------------------------------------------------------------------------------- /templates/backup.yaml.j2: -------------------------------------------------------------------------------- 1 | version: "2.1" 2 | services: 3 | backup_odoo: 4 | image: ghcr.io/tecnativa/docker-duplicity-postgres:master 5 | hostname: {{ inventory_hostname_short | lower | regex_replace('_','') }}-{{ item.key }} 6 | environment: 7 | DST: "swift://{{ item.key }}_{{ inventory_hostname|lower }}" 8 | PGDATABASE: "{{ item.value.db }}" 9 | PGUSER: "{{ item.value.db_user }}" 10 | PGPASSWORD: "{{ item.value.db_pass }}" 11 | PASSPHRASE: "{{ item.value.odoo_backup_pass | default(item.value.master_pass) }}" 12 | SWIFT_USERNAME: "{{ account.username }}" 13 | SWIFT_PASSWORD: "{{ account.password }}" 14 | SWIFT_AUTHURL: "{{ account.authurl }}" 15 | SWIFT_AUTHVERSION: {{ account.authversion }} 16 | SWIFT_TENANTNAME: "{{ account.tenantname }}" 17 | SWIFT_TENANTID: "{{ account.tenantid }}" 18 | SWIFT_REGIONNAME: "{{ account.regionname }}" 19 | JOB_200_WHEN: "never" 20 | JOB_300_WHAT: "pg_dump --no-owner --format c --file $$SRC/$$PGDATABASE.pgdump && backup --full-if-older-than 6D" 21 | JOB_302_WHAT: "dup remove-all-but-n-full 5 --force $$DST $$@" 22 | JOB_302_WHEN: "daily" 23 | volumes: 24 | - {{ item.key }}{{ account_index + 1 }}_backup_cache:/root/.cache/duplicity/:z 25 | - {{ item.key }}_filestore:/mnt/backup/src/odoo:z 26 | {% if item.value.metabase | default(false) %} 27 | - {{ item.key }}_metabase:/mnt/backup/src/metabase:z 28 | {% endif %} 29 | networks: 30 | - {{ item.key }}_default 31 | - public 32 | command: 33 | - /etc/periodic/daily/jobrunner 34 | 35 | networks: 36 | {{ item.key }}_default: 37 | external: true 38 | public: 39 | driver_opts: 40 | encrypted: 1 41 | 42 | volumes: 43 | {{ item.key }}{{ account_index + 1 }}_backup_cache: 44 | {{ item.key }}_filestore: 45 | external: true 46 | {% if item.value.metabase | default(false) %} 47 | {{ item.key }}_metabase: 48 | external: true 49 | {% endif %} 50 | -------------------------------------------------------------------------------- /templates/docker-compose.yaml.j2: -------------------------------------------------------------------------------- 1 | version: "2.1" 2 | services: 3 | odoo: 4 | {# if instance is to be built #} 5 | {% if item.value.image_instance | default(false) == item.key %} 6 | build: 7 | context: ./odoo 8 | {% endif %} 9 | image: filament/{{ item.key }}:{{ instance_odoo_setup.odoo_version }} 10 | container_name: {{ item.key }} 11 | depends_on: 12 | - db 13 | - smtp 14 | environment: 15 | PGDATABASE: "{{ item.value.db }}" 16 | {% if item.value.odoo_extra_host is defined %} 17 | extra_hosts: 18 | - "{{ item.value.odoo_extra_host }}" 19 | {% endif %} 20 | tty: true 21 | volumes: 22 | - filestore:/opt/odoo/data:z 23 | {# if prod and banking #} 24 | {% if item.value.prod_instance | default(false) == item.key and banking | default(false) %} 25 | - ./bank/:/ofx/:ro 26 | {% endif %} 27 | {% if private_pull is defined %} 28 | - ../import/:/import/:ro 29 | {% endif %} 30 | networks: 31 | default: 32 | inverseproxy_shared: 33 | {% if restrict_internet_access %} 34 | {% if whitelisted_urls is defined %} 35 | whitelists_proxy: 36 | {% endif %} 37 | {% if item.value.extra_urls is defined %} 38 | extrawhitelists_proxy: 39 | {% endif %} 40 | {% endif %} 41 | {# if prod and mailname #} 42 | {% if item.value.prod_instance | default(false) == item.key and mailname | default(false) %} 43 | email_proxy: 44 | {% endif %} 45 | restart: unless-stopped 46 | labels: 47 | {# if prod #} 48 | {% if item.value.prod_instance | default(false) == item.key %} 49 | co.elastic.logs/multiline.pattern: '^[0-9]{2}' 50 | co.elastic.logs/multiline.negate: 'true' 51 | co.elastic.logs/multiline.match: "after" 52 | {% else %} 53 | co.elastic.logs/enabled: "false" 54 | {% endif %} 55 | traefik.enable: "true" 56 | {% if ansible_processor_vcpus > 2 or item.value.force_odoo_workers is defined %} 57 | traefik.http.routers.{{ item.key }}-{{ instance_odoo_setup.websocket_uri }}.rule: "Host(`{{ item.value.url }}`{% if item.value.url2 is defined %}, `{{ item.value.url2 }}`{% endif %}) && PathPrefix(`/{{ instance_odoo_setup.websocket_uri }}/`)" 58 | traefik.http.routers.{{ item.key }}-{{ instance_odoo_setup.websocket_uri }}.service: "{{ item.key }}-{{ instance_odoo_setup.websocket_uri }}" 59 | traefik.http.services.{{ item.key }}-{{ instance_odoo_setup.websocket_uri }}.loadbalancer.server.port: "8072" 60 | {% endif %} 61 | traefik.http.routers.{{ item.key }}-restrict.middlewares: "auth@file" 62 | traefik.http.routers.{{ item.key }}-restrict.rule: "Host(`{{ item.value.url }}`{% if item.value.url2 is defined %}, `{{ item.value.url2 }}`{% endif %}) && Path(`/website/info`, `/web/database/{p:manager|create|duplicate|drop|backup|restore|change_password}`)" 63 | traefik.http.routers.{{ item.key }}-restrict.service: "{{ item.key }}" 64 | traefik.http.routers.{{ item.key }}.rule: "Host(`{{ item.value.url }}`{% if item.value.url2 is defined %}, `{{ item.value.url2 }}`{% endif %})" 65 | traefik.http.routers.{{ item.key }}.service: "{{ item.key }}" 66 | traefik.http.services.{{ item.key }}.loadbalancer.server.port: "8069" 67 | {# if not prod #} 68 | {% if item.value.prod_instance | default(false) != item.key %} 69 | traefik.http.routers.{{ item.key }}.middlewares: "norobot-headers@file" 70 | command: 71 | - odoo 72 | - --smtp-port=1025 73 | - --database={{ item.value.db }} 74 | - --init=web_environment_ribbon 75 | {% if ansible_processor_vcpus > 2 or item.value.force_odoo_workers is defined %} 76 | - --workers=2 77 | - --max-cron-threads=1 78 | {% endif %} 79 | {% endif %} 80 | 81 | db: 82 | image: postgres:{{ instance_odoo_setup.postgres_version }}-alpine 83 | container_name: {{ item.key }}_db 84 | environment: 85 | POSTGRES_DB: "postgres" 86 | POSTGRES_USER: "{{ odoo_instances[item.value.prod_instance | default(item.key)].db_user }}" 87 | POSTGRES_PASSWORD: "{{ odoo_instances[item.value.prod_instance | default(item.key)].db_pass }}" 88 | {% if item.value.postgres_options is defined %} 89 | command: {{ item.value.postgres_options }} 90 | {% endif %} 91 | labels: 92 | {# if prod #} 93 | {% if item.value.prod_instance | default(false) == item.key %} 94 | co.elastic.logs/module: postgresql 95 | {% else %} 96 | co.elastic.logs/enabled: "false" 97 | {% endif %} 98 | {% if item.value.odoo_remote_db_access | default(false) %} 99 | networks: 100 | default: 101 | public: 102 | ports: 103 | - "{{ item.value.odoo_remote_db_access_port }}:5432" 104 | {% endif %} 105 | volumes: 106 | - db:/var/lib/postgresql/data:z 107 | restart: unless-stopped 108 | 109 | smtp: 110 | {# if prod and mailname #} 111 | {% if item.value.prod_instance | default(false) == item.key and mailname | default(false) %} 112 | image: tecnativa/postfix-relay 113 | container_name: {{ item.key }}_smtp 114 | networks: 115 | email_proxy: 116 | volumes: 117 | - smtp:/var/spool/postfix 118 | environment: 119 | MAILNAME: "{{ mailname }}" 120 | MAIL_RELAY_HOST: "{{ mailserver }}" 121 | MAIL_RELAY_PORT: "{{ smtpport }}" 122 | MAIL_RELAY_USER: "{{ smtpuser }}" 123 | MAIL_RELAY_PASS: "{{ smtppass }}" 124 | MAIL_CANONICAL_DOMAINS: "{{ mailname }}" 125 | MAIL_NON_CANONICAL_DEFAULT: "{{ mailname }}" 126 | restart: unless-stopped 127 | 128 | {% if restrict_internet_access %} 129 | {% if imap_mailserver is defined %} 130 | email_imap: 131 | image: tecnativa/whitelist 132 | container_name: {{ item.key }}_imap 133 | labels: 134 | co.elastic.logs/enabled: "false" 135 | networks: 136 | email_proxy: 137 | aliases: 138 | - "{{ imap_mailserver }}" 139 | email_public: 140 | environment: 141 | PORT: "443 993" 142 | TARGET: "{{ imap_mailserver }}" 143 | PRE_RESOLVE: 1 144 | restart: unless-stopped 145 | 146 | {% endif %} 147 | email: 148 | image: tecnativa/whitelist 149 | container_name: {{ item.key }}_email 150 | labels: 151 | co.elastic.logs/enabled: "false" 152 | networks: 153 | email_proxy: 154 | aliases: 155 | - "{{ mailserver }}" 156 | email_public: 157 | environment: 158 | PORT: "443 {{ smtpport }} 993" 159 | TARGET: "{{ mailserver }}" 160 | PRE_RESOLVE: 1 161 | restart: unless-stopped 162 | 163 | {% endif %} 164 | {% else %} 165 | image: mailhog/mailhog 166 | container_name: {{ item.key }}_smtp 167 | restart: unless-stopped 168 | labels: 169 | co.elastic.logs/enabled: "false" 170 | {# if not prod #} 171 | {% if item.value.prod_instance | default(false) != item.key %} 172 | traefik.docker.network: "inverseproxy_smtp" 173 | traefik.enable: "true" 174 | traefik.http.routers.{{ item.key }}smtp.middlewares: "auth@file, smtp-stripprefix@file" 175 | traefik.http.routers.{{ item.key }}smtp.rule: "Host(`{{ item.value.url }}`) && PathPrefix(`/smtp/`)" 176 | traefik.http.routers.{{ item.key }}smtp.service: "{{ item.key }}smtp" 177 | traefik.http.services.{{ item.key }}smtp.loadbalancer.server.port: "8025" 178 | networks: 179 | default: 180 | inverseproxy_smtp: 181 | {% endif %} 182 | 183 | {% endif %} 184 | {% if restrict_internet_access and item.value.extra_urls is defined %} 185 | {% for server in item.value.extra_urls %} 186 | {{ server.url }}: 187 | image: tecnativa/whitelist 188 | container_name: {{ item.key }}_{{ server.url }} 189 | labels: 190 | co.elastic.logs/enabled: "false" 191 | networks: 192 | extrawhitelists_proxy: 193 | aliases: 194 | - "{{ server.url }}" 195 | extrawhitelists_public: 196 | environment: 197 | PORT: "{{ server.port }}" 198 | TARGET: "{{ server.url }}" 199 | PRE_RESOLVE: 1 200 | restart: unless-stopped 201 | 202 | {% endfor %} 203 | {% endif %} 204 | {% if item.value.metabase | default(false) %} 205 | metabase: 206 | image: metabase/metabase 207 | container_name: {{ item.key }}_metabase 208 | environment: 209 | MB_DB_FILE: "/metabase-data/metabase.db" 210 | networks: 211 | default: 212 | inverseproxy_bi: 213 | labels: 214 | co.elastic.logs/enabled: "false" 215 | traefik.docker.network: "inverseproxy_bi" 216 | traefik.enable: "true" 217 | traefik.http.middlewares.metabase-stripprefix.stripprefix.prefixes: "/metabase" 218 | traefik.http.routers.metabase.middlewares: "metabase-stripprefix" 219 | traefik.http.routers.metabase.rule: "Host(`{{ item.value.url }}`) && PathPrefix(`/metabase`)" 220 | traefik.http.routers.metabase.service: "metabase" 221 | traefik.http.services.metabase.loadbalancer.server.port: "3000" 222 | restart: unless-stopped 223 | volumes: 224 | - metabase:/metabase-data:z 225 | 226 | {% endif %} 227 | {% if item.value.extra_app is defined %} 228 | app: 229 | image: {{ item.value.extra_app.image }} 230 | container_name: {{ item.value.extra_app.name }} 231 | restart: unless-stopped 232 | networks: 233 | inverseproxy_app: 234 | labels: 235 | co.elastic.logs/enabled: "false" 236 | traefik.docker.network: "inverseproxy_app" 237 | traefik.enable: "true" 238 | traefik.http.routers.{{ item.value.extra_app.name | lower | regex_replace('_','') }}.rule: "Host(`{{ item.value.extra_app.url }}`)" 239 | traefik.http.routers.{{ item.value.extra_app.name | lower | regex_replace('_','') }}.service: "{{ item.value.extra_app.name | lower | regex_replace('_','') }}" 240 | traefik.http.services.{{ item.value.extra_app.name | lower | regex_replace('_','') }}.loadbalancer.server.port: "80" 241 | 242 | {% endif %} 243 | networks: 244 | default: 245 | internal: true 246 | driver_opts: 247 | encrypted: 1 248 | inverseproxy_shared: 249 | external: true 250 | {# if not prod #} 251 | {% if item.value.prod_instance | default(false) != item.key %} 252 | inverseproxy_smtp: 253 | external: true 254 | {% endif %} 255 | {% if item.value.extra_app is defined %} 256 | inverseproxy_app: 257 | external: true 258 | {% endif %} 259 | {% if item.value.metabase | default(false) %} 260 | inverseproxy_bi: 261 | external: true 262 | {% endif %} 263 | {% if restrict_internet_access %} 264 | {% if whitelisted_urls is defined %} 265 | whitelists_proxy: 266 | external: true 267 | {% endif %} 268 | {% if item.value.extra_urls is defined %} 269 | extrawhitelists_proxy: 270 | driver_opts: 271 | encrypted: 1 272 | internal: true 273 | extrawhitelists_public: 274 | driver_opts: 275 | encrypted: 1 276 | {% endif %} 277 | {% endif %} 278 | {# if prod and mailname #} 279 | {% if item.value.prod_instance | default(false) == item.key and mailname | default(false) %} 280 | email_proxy: 281 | driver_opts: 282 | encrypted: 1 283 | {% if restrict_internet_access %} 284 | internal: true 285 | email_public: 286 | driver_opts: 287 | encrypted: 1 288 | {% endif %} 289 | {% endif %} 290 | {% if item.value.odoo_remote_db_access | default(false) %} 291 | public: 292 | {% endif %} 293 | 294 | volumes: 295 | filestore: 296 | db: 297 | {# if prod and mailname #} 298 | {% if item.value.prod_instance | default(false) == item.key and mailname | default(false) %} 299 | smtp: 300 | {% endif %} 301 | {% if item.value.metabase | default(false) %} 302 | metabase: 303 | {% endif %} 304 | -------------------------------------------------------------------------------- /templates/fetch_repos: -------------------------------------------------------------------------------- 1 | {% if instance_odoo_setup.odoo_version == '10.0' %} 2 | #!/usr/bin/env python 3 | {% else %} 4 | #!/usr/bin/env python3 5 | {% endif %} 6 | # -*- coding: utf-8 -*- 7 | import grp 8 | import os 9 | import pwd 10 | import shutil 11 | from subprocess import call 12 | import yaml 13 | 14 | DEFAULT_PRIVATE_REPO = "/opt/odoo/private_addons" 15 | REPO_FILE = "/opt/odoo/private/repos.yaml" 16 | UID = pwd.getpwnam("odoo").pw_uid 17 | GID = grp.getgrnam("odoo").gr_gid 18 | 19 | if os.path.isfile(REPO_FILE): 20 | repos = yaml.safe_load(open(REPO_FILE)) 21 | if repos: 22 | for repo in repos: 23 | call(["git", "clone", "-b", repos[repo]["branch"], "--depth", "1", repos[repo]["url"], 24 | DEFAULT_PRIVATE_REPO+"/"+repo]) 25 | 26 | {% if instance_odoo_setup.odoo_version == '10.0' %} 27 | if os.path.isdir("/opt/odoo/private_addons/lf_theme"): 28 | if not os.path.isfile("/opt/odoo/private_addons/lf_theme/static\ 29 | /src/less/lefilament_variable.less"): 30 | shutil.copy("/opt/odoo/private_addons/lf_theme/static/src/less/lefilament_variable_origin.less", "/opt/odoo/private_addons/lf_theme/static/src/less/lefilament_variable.less") 31 | {% endif %} 32 | -------------------------------------------------------------------------------- /templates/fetch_repos_addons: -------------------------------------------------------------------------------- 1 | {% if instance_odoo_setup.odoo_version == '10.0' %} 2 | #!/usr/bin/env python 3 | {% else %} 4 | #!/usr/bin/env python3 5 | {% endif %} 6 | # -*- coding: utf-8 -*- 7 | import grp 8 | import os 9 | import pwd 10 | import shutil 11 | from subprocess import call 12 | {% if instance_odoo_setup.odoo_version == '10.0' %} 13 | from urlparse import urlsplit 14 | {% else %} 15 | from urllib.parse import urlsplit 16 | {% endif %} 17 | import yaml 18 | 19 | DEFAULT_PRIVATE_REPO = "/opt/odoo/additional_addons" 20 | REPO_ADDON_FILE = "/opt/odoo/private/repos-addons.yaml" 21 | UID = pwd.getpwnam("odoo").pw_uid 22 | GID = grp.getgrnam("odoo").gr_gid 23 | 24 | if os.path.isfile(REPO_ADDON_FILE): 25 | repos = yaml.safe_load(open(REPO_ADDON_FILE)) 26 | if repos: 27 | for url in repos: 28 | repo = urlsplit(url).path 29 | call(["git", "clone", "-b", repos[url]["branch"], "--depth", "1", 30 | url, "/tmp/addon"+repo]) 31 | for module in repos[url]["modules"]: 32 | shutil.move("/tmp/addon"+repo+"/"+module, 33 | DEFAULT_PRIVATE_REPO+"/"+module) 34 | 35 | shutil.rmtree("/tmp/addon") 36 | -------------------------------------------------------------------------------- /templates/odoo.conf.j2: -------------------------------------------------------------------------------- 1 | [options] 2 | ;; COMMON OPTIONS 3 | addons_path = /opt/odoo/odoo/addons,/opt/odoo/additional_addons,/opt/odoo/private_addons 4 | admin_passwd = {{ odoo_instances[item.value.prod_instance | default(item.key )].master_pass | password_hash('pbkdf2_sha512', 65534 | random(seed=inventory_hostname) | string) }} 5 | data_dir = /opt/odoo/data 6 | {% if instance_odoo_setup.odoo_version == '12.0' or instance_odoo_setup.odoo_version == '14.0' or instance_odoo_setup.odoo_version == '16.0' %} 7 | server_wide_modules = base,web,module_change_auto_install{% if item.value.odoo_server_wide_modules is defined %},{{ item.value.odoo_server_wide_modules }}{% endif %} 8 | {% endif %} 9 | 10 | without_demo = all 11 | 12 | ;; HTTP Service Configuration 13 | ; gevent_port = 8072 14 | ; http_enable = True 15 | ; http_interface = 16 | ; http_port = 8069 17 | proxy_mode = True 18 | ; x_sendfile = False 19 | 20 | ;; Web interface Configuration 21 | ; dbfilter = 22 | 23 | ;; Logging Configuration 24 | ; log_db = False 25 | ; log_db_level = warning 26 | ; log_handler = [':INFO'] 27 | ; log_level = info 28 | ; logfile = None 29 | ; syslog = False 30 | 31 | ;; SMTP Configuration 32 | ; email_from = False 33 | ; from_filter = False 34 | ; smtp_password = False 35 | {% if mailname is defined %} 36 | ; smtp_port = 25 37 | {% else %} 38 | smtp_port=1025 39 | {% endif %} 40 | smtp_server = smtp 41 | ; smtp_ssl = False 42 | ; smtp_ssl_certificate_filename = False 43 | ; smtp_ssl_private_key_filename = False 44 | ; smtp_user = False 45 | 46 | ;; Database related options 47 | db_name = {{ odoo_instances[item.value.prod_instance | default(item.key )].db }} 48 | db_password = {{ odoo_instances[item.value.prod_instance | default(item.key )].db_pass }} 49 | db_user = {{ odoo_instances[item.value.prod_instance | default(item.key )].db_user }} 50 | ; db_template = template0 51 | db_host = db 52 | db_maxconn = {{ odoo_instances[item.value.prod_instance | default(item.key )].odoo_db_maxconn | default(64) }} 53 | ; db_sslmode = prefer 54 | ; pg_path = 55 | 56 | ;; Security-related options 57 | ; list_db = True 58 | 59 | ;; Advanced options 60 | ; geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb 61 | ; osv_memory_count_limit = 0 62 | ; transient_age_limit = 1.0 63 | unaccent = True 64 | 65 | ;; Multiprocessing options 66 | ; limit_memory_hard = 2684354560 67 | ; limit_memory_soft = 2147483648 68 | ; limit_request = 65536 69 | limit_time_cpu = {{ odoo_instances[item.value.prod_instance | default(item.key )].odoo_limit_time_cpu | default(300) }} 70 | limit_time_real = {{ odoo_instances[item.value.prod_instance | default(item.key )].odoo_limit_time_real | default(600) }} 71 | ; limit_time_real_cron = -1 72 | {% if ansible_processor_vcpus > 2 or odoo_instances[item.value.prod_instance | default(item.key )].force_odoo_workers is defined %} 73 | max_cron_threads = {{ ansible_processor_vcpus | int }} 74 | workers = {{ (ansible_processor_vcpus * 2 - 1) | int | abs }} 75 | {% else %} 76 | ; max_cron_threads = 2 77 | ; workers = 0 78 | {% endif %} 79 | {% if instance_odoo_setup.odoo_version == '12.0' %} 80 | 81 | ;; Autoinstall options 82 | modules_auto_install_disabled = account_facturx,mail_bot,web_unsplash{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled }}{% endif %} 83 | 84 | modules_auto_install_enabled = disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_odoo_enterprise,web_responsive,web_no_bubble{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled }}{% endif %} 85 | 86 | {% endif %} 87 | {% if instance_odoo_setup.odoo_version == '14.0' %} 88 | 89 | ;; Autoinstall options 90 | modules_auto_install_disabled = account_edi,mail_bot,web_unsplash{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled }}{% endif %} 91 | 92 | modules_auto_install_enabled = account_move_name_sequence,account_reconcile_show_boolean,account_reconciliation_widget,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_login_links,remove_odoo_enterprise,web_responsive,web_no_bubble{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled }}{% endif %} 93 | 94 | {% endif %} 95 | {% if instance_odoo_setup.odoo_version == '16.0' %} 96 | 97 | ;; Autoinstall options 98 | modules_auto_install_disabled = account_edi,google_gmail,mail_bot,web_unsplash{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_disabled }}{% endif %} 99 | 100 | ; to be updated once all modules are available 101 | modules_auto_install_enabled = account_move_name_sequence,disable_odoo_online,lefilament_release_agent,partner_disable_gravatar,partner_firstname,remove_login_links,remove_odoo_enterprise,web_responsive,web_theme_classic{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled }}{% endif %} 102 | ; modules_auto_install_enabled = account_move_name_sequence,account_reconcile_show_boolean,account_reconcile_oca,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_login_links,remove_odoo_enterprise,web_responsive,web_no_bubble,web_theme_classic{% if odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled is defined %},{{ odoo_instances[item.value.prod_instance | default(item.key )].modules_auto_install_enabled }}{% endif %} 103 | 104 | {% endif %} 105 | {% if odoo_instances[item.value.prod_instance | default(item.key )].odoo_extra_conf is defined %} 106 | 107 | ;; Extra options 108 | {{ odoo_instances[item.value.prod_instance | default(item.key )].odoo_extra_conf }} 109 | {% endif %} 110 | -------------------------------------------------------------------------------- /templates/post_restore-odootest.sql.j2: -------------------------------------------------------------------------------- 1 | UPDATE ir_cron SET active=false; 2 | UPDATE fetchmail_server SET active=false; 3 | UPDATE ir_mail_server SET active=false; 4 | -------------------------------------------------------------------------------- /templates/pre_restore-odootest.sql.j2: -------------------------------------------------------------------------------- 1 | REVOKE CONNECT ON DATABASE {{ item.value.db }} FROM public; 2 | SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '{{ item.value.db }}'; 3 | DROP DATABASE {{ item.value.db }}; 4 | -------------------------------------------------------------------------------- /templates/pull_remote_files.sh.j2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright © 2019 Le Filament () 4 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). 5 | 6 | sftp {{ private_user }}@{{ private_server }} << COMMANDS 7 | get {{ private_rpath }}{{ private_rfname }} /home/docker/import/ 8 | quit 9 | COMMANDS 10 | 11 | mv -f `ls -Art /home/docker/import/{{ private_rfname }} | tail -n 1` /home/docker/import/{{ private_lfname }} 12 | -------------------------------------------------------------------------------- /templates/repos-addons.yaml.j2: -------------------------------------------------------------------------------- 1 | {% for repo in item.value.other_modules | default([]) | sort(attribute='url') %} 2 | {{ repo.url }}: 3 | {% if repo.branch is defined %} 4 | branch: "{{ repo.branch }}" 5 | {% else %} 6 | branch: "{{ instance_odoo_setup.odoo_version }}" 7 | {% endif %} 8 | modules: 9 | {% for modules in repo.modules | sort %} 10 | - {{ modules }} 11 | {% endfor %} 12 | {% endfor %} 13 | {% for repo in item.value.custom_modules_oca | default([]) | sort(attribute='repo') %} 14 | https://github.com/OCA/{{ repo.repo }}.git: 15 | {% if repo.branch is defined %} 16 | branch: "{{ repo.branch }}" 17 | {% else %} 18 | branch: "{{ instance_odoo_setup.odoo_version }}" 19 | {% endif %} 20 | modules: 21 | {% for modules in repo.modules | sort %} 22 | - {{ modules }} 23 | {% endfor %} 24 | {% endfor %} 25 | -------------------------------------------------------------------------------- /templates/repos.yaml.j2: -------------------------------------------------------------------------------- 1 | {% for repo in item.value.custom_modules | default([]) | sort(attribute='repo') %} 2 | {{ repo.repo | basename }}: 3 | url: "{{ custom_modules_base_url }}/{{ repo.repo }}.git" 4 | {% if repo.branch is defined %} 5 | branch: "{{ repo.branch }}" 6 | {% else %} 7 | branch: "{{ instance_odoo_setup.odoo_version }}" 8 | {% endif %} 9 | {% endfor %} 10 | {% for repo in item.value.other_repos | default([]) | sort(attribute='repo') %} 11 | {{ repo.repo }}: 12 | url: {{ repo.url }} 13 | {% if repo.branch is defined %} 14 | branch: "{{ repo.branch }}" 15 | {% else %} 16 | branch: "{{ instance_odoo_setup.odoo_version }}" 17 | {% endif %} 18 | {% endfor %} 19 | -------------------------------------------------------------------------------- /templates/restore-odootest.yaml.j2: -------------------------------------------------------------------------------- 1 | version: "2.1" 2 | services: 3 | restore_test: 4 | image: ghcr.io/tecnativa/docker-duplicity-postgres:master 5 | hostname: {{ item.value.backup_host | default(inventory_hostname_short) | lower | regex_replace('_','') }}-odoo 6 | networks: 7 | - {{ item.key }}_default 8 | - public 9 | volumes: 10 | - backups_{{ item.value.backup_instance }}{{ account_index + 1 }}_backup_cache:/root/.cache/duplicity/:z 11 | - {{ item.key }}_filestore:/mnt/backup/src/odoo:z 12 | - ./post_restore-{{ item.key }}.sql:/tmp/post-restore.sql:ro 13 | - ./pre_restore-{{ item.key }}.sql:/tmp/pre-restore.sql:ro 14 | environment: 15 | PGDATABASE: "{{ item.value.db }}" 16 | SWIFT_USERNAME: "{{ account.username }}" 17 | SWIFT_PASSWORD: "{{ account.password }}" 18 | SWIFT_AUTHURL: "{{ account.authurl }}" 19 | SWIFT_AUTHVERSION: {{ account.authversion }} 20 | SWIFT_TENANTNAME: "{{ account.tenantname }}" 21 | SWIFT_TENANTID: "{{ account.tenantid }}" 22 | SWIFT_REGIONNAME: "{{ account.regionname }}" 23 | OPTIONS: "--force" 24 | DST: "swift://{{ item.value.backup_instance }}_{{ item.value.backup_host | default(inventory_hostname) | lower }}" 25 | PGUSER: "{{ odoo_instances[item.value.prod_instance | default(item.key )].db_user }}" 26 | PGPASSWORD: "{{ odoo_instances[item.value.prod_instance | default(item.key )].db_pass }}" 27 | PASSPHRASE: "{{ hostvars[item.value.backup_host | default(inventory_hostname)]['odoo_instances'][item.value.backup_instance].odoo_backup_pass | default(hostvars[item.value.backup_host | default(inventory_hostname)]['odoo_instances'][item.value.backup_instance].master_pass) }}" 28 | command: [sh, -c, "psql -a -f /tmp/pre-restore.sql postgres ; echo 'remove existing dir' && rm -rf /mnt/backup/src/odoo/filestore/$$PGDATABASE && restore && echo 'move repo to final dest' && mv /mnt/backup/src/odoo/filestore/{{ hostvars[item.value.backup_host | default(inventory_hostname)]['odoo_instances'][item.value.backup_instance].db }} /mnt/backup/src/odoo/filestore/$$PGDATABASE && echo 'create database' && createdb -T template0 $$PGDATABASE && echo 'restore database' && pg_restore -d $$PGDATABASE $$SRC/{{ hostvars[item.value.backup_host | default(inventory_hostname)]['odoo_instances'][item.value.backup_instance].db }}.pgdump ; psql -a -f /tmp/post-restore.sql $$PGDATABASE"] 29 | 30 | networks: 31 | {{ item.key }}_default: 32 | external: true 33 | public: 34 | driver_opts: 35 | encrypted: 1 36 | 37 | volumes: 38 | backups_{{ item.value.backup_instance }}{{ account_index + 1 }}_backup_cache: 39 | {% if item.value.backup_host | default(inventory_hostname) == inventory_hostname %} 40 | external: true 41 | {% endif %} 42 | {{ item.key }}_filestore: 43 | external: true 44 | -------------------------------------------------------------------------------- /templates/whitelists.yaml.j2: -------------------------------------------------------------------------------- 1 | version: "2.1" 2 | services: 3 | {% for url in whitelisted_urls %} 4 | 5 | {{ url }}: 6 | image: tecnativa/whitelist 7 | environment: 8 | TARGET: "{{ url }}" 9 | PRE_RESOLVE: 1 10 | labels: 11 | co.elastic.logs/enabled: "false" 12 | networks: 13 | proxy: 14 | aliases: 15 | - "{{ url }}" 16 | public: 17 | restart: unless-stopped 18 | {% endfor %} 19 | 20 | networks: 21 | proxy: 22 | internal: true 23 | driver_opts: 24 | encrypted: 1 25 | public: 26 | driver_opts: 27 | encrypted: 1 28 | --------------------------------------------------------------------------------