From 781e7defd174b74f2d19d1771e9e4c877380c55b Mon Sep 17 00:00:00 2001 From: Hussam Date: Mon, 10 Sep 2018 09:34:46 +0000 Subject: [PATCH] hi --- .directory | 6 + .gitignore | 2 + .travis.yml | 74 -- LICENCE.md | 636 ------------------ README.md | 239 ------- barman/README.md | 303 +++++++++ barman/defaults/main.yml | 14 + barman/tasks/main.yml | 283 ++++++++ barman/templates/barman-server.conf.j2 | 15 + barman/templates/postgresql.conf.j2 | 626 +++++++++++++++++ defaults/main.yml | 142 ---- files/bootstrap.py | 210 ------ lxd/README.md | 303 +++++++++ lxd/defaults/main.yml | 17 + lxd/tasks/main.yml | 174 +++++ meta/main.yml | 19 - msmtp/README.md | 303 +++++++++ msmtp/defaults/main.yml | 20 + msmtp/tasks/main.yml | 104 +++ msmtp/templates/mail.j2 | 22 + msmtp/templates/msmtp.j2 | 23 + nginx/README.md | 303 +++++++++ nginx/defaults/main.yml | 13 + nginx/tasks/main.yml | 100 +++ nginx/templates/nginx-proxy.j2 | 56 ++ odoo/README.md | 303 +++++++++ odoo/defaults/main.yml | 50 ++ odoo/files/odoo_cfg_files/base3.cfg | 81 +++ odoo/files/odoo_cfg_files/buildout.cfg | 44 ++ {handlers => odoo/handlers}/main.yml | 6 +- odoo/tasks/main.yml | 412 ++++++++++++ .../templates}/odoo-buildout.init | 0 .../templates}/odoo-buildout.service | 0 .../vars/Odoo-10.yml | 20 +- .../vars/Odoo-11.yml | 33 +- .../vars/Odoo-8.yml | 17 +- .../vars/Odoo-9.yml | 16 +- {vars => odoo/vars}/Ubuntu-16_Odoo-10.yml | 2 +- {vars => odoo/vars}/Ubuntu-16_Odoo-11.yml | 3 +- {vars => odoo/vars}/Ubuntu-16_Odoo-8.yml | 3 +- {vars => odoo/vars}/Ubuntu-16_Odoo-9.yml | 2 +- {vars => odoo/vars}/main.yml | 7 + postgresql/README.md | 303 +++++++++ postgresql/defaults/main.yml | 9 + postgresql/tasks/main.yml | 94 +++ rsnapshot/README.md | 303 +++++++++ rsnapshot/defaults/main.yml | 9 + rsnapshot/tasks/main.yml | 174 +++++ rsnapshot/templates/exclude.txt.j2 | 44 ++ rsnapshot/templates/include.txt.j2 | 3 + rsnapshot/templates/rsnapshot.conf.j2 | 264 ++++++++ tasks/config.yml | 8 - tasks/install.yml | 96 --- tasks/install_buildout.yml | 39 -- tasks/install_npm.yml | 24 - tasks/install_pip.yml | 47 -- tasks/install_ssh.yml | 54 -- tasks/install_standard.yml | 20 - tasks/main.yml | 33 - tasks/postgresql.yml | 30 - tasks/reportlab.yml | 20 - tasks/service.yml | 75 --- tasks/wkhtmltox.yml | 39 -- templates/odoo-10.0-pip-requirements.txt | 2 - templates/odoo-10.0.conf | 64 -- templates/odoo-10.0.conf.orig | 57 -- templates/odoo-10.0.init | 81 --- templates/odoo-11.0-pip-requirements.txt | 2 - templates/odoo-11.0.conf | 65 -- templates/odoo-11.0.conf.orig | 58 -- templates/odoo-11.0.init | 1 - templates/odoo-8.0-pip-requirements.txt | 1 - templates/odoo-8.0.conf | 70 -- templates/odoo-8.0.init | 81 --- templates/odoo-9.0-pip-requirements.txt | 1 - templates/odoo-9.0.conf | 65 -- templates/odoo-9.0.conf.orig | 58 -- templates/odoo-9.0.init | 81 --- templates/odoo-pip.init | 88 --- templates/odoo-pip.service | 16 - templates/odoo-standard.service | 20 - tests/install_test_env.sh | 14 - tests/inventory | 1 - tests/run.sh | 44 -- tests/test_buildout.yml | 9 - tests/test_buildout_changed.yml | 11 - tests/test_pip.yml | 11 - tests/test_pip_changed.yml | 13 - tests/test_standard.yml | 9 - tests/test_standard_changed.yml | 11 - tests/travis_lxd/create_container.sh | 18 - tests/travis_lxd/fix_debian_jessie.sh | 21 - tests/travis_lxd/install.sh | 9 - tests/travis_lxd/lxd-debconf | 22 - vars/Debian-8_Odoo-10.yml | 109 --- vars/Debian-8_Odoo-8.yml | 97 --- vars/Debian-8_Odoo-9.yml | 104 --- vars/Debian-9_Odoo-10.yml | 106 --- vars/Debian-9_Odoo-8.yml | 93 --- vars/Debian-9_Odoo-9.yml | 102 --- 100 files changed, 4857 insertions(+), 3452 deletions(-) create mode 100755 .directory create mode 100644 .gitignore delete mode 100644 .travis.yml delete mode 100644 LICENCE.md delete mode 100644 README.md create mode 100755 barman/README.md create mode 100755 barman/defaults/main.yml create mode 100755 barman/tasks/main.yml create mode 100755 barman/templates/barman-server.conf.j2 create mode 100755 barman/templates/postgresql.conf.j2 delete mode 100644 defaults/main.yml delete mode 100644 files/bootstrap.py create mode 100755 lxd/README.md create mode 100755 lxd/defaults/main.yml create mode 100755 lxd/tasks/main.yml delete mode 100644 meta/main.yml create mode 100755 msmtp/README.md create mode 100755 msmtp/defaults/main.yml create mode 100755 msmtp/tasks/main.yml create mode 100755 msmtp/templates/mail.j2 create mode 100755 msmtp/templates/msmtp.j2 create mode 100755 nginx/README.md create mode 100755 nginx/defaults/main.yml create mode 100755 nginx/tasks/main.yml create mode 100755 nginx/templates/nginx-proxy.j2 create mode 100755 odoo/README.md create mode 100755 odoo/defaults/main.yml create mode 100755 odoo/files/odoo_cfg_files/base3.cfg create mode 100755 odoo/files/odoo_cfg_files/buildout.cfg rename {handlers => odoo/handlers}/main.yml (54%) mode change 100644 => 100755 create mode 100755 odoo/tasks/main.yml rename {templates => odoo/templates}/odoo-buildout.init (100%) mode change 100644 => 100755 rename {templates => odoo/templates}/odoo-buildout.service (100%) mode change 100644 => 100755 rename vars/Ubuntu-14_Odoo-10.yml => odoo/vars/Odoo-10.yml (69%) mode change 100644 => 100755 rename vars/Debian-9_Odoo-11.yml => odoo/vars/Odoo-11.yml (71%) mode change 100644 => 100755 rename vars/Ubuntu-14_Odoo-8.yml => odoo/vars/Odoo-8.yml (65%) mode change 100644 => 100755 rename vars/Ubuntu-14_Odoo-9.yml => odoo/vars/Odoo-9.yml (68%) mode change 100644 => 100755 rename {vars => odoo/vars}/Ubuntu-16_Odoo-10.yml (99%) mode change 100644 => 100755 rename {vars => odoo/vars}/Ubuntu-16_Odoo-11.yml (98%) mode change 100644 => 100755 rename {vars => odoo/vars}/Ubuntu-16_Odoo-8.yml (99%) mode change 100644 => 100755 rename {vars => odoo/vars}/Ubuntu-16_Odoo-9.yml (99%) mode change 100644 => 100755 rename {vars => odoo/vars}/main.yml (99%) mode change 100644 => 100755 create mode 100755 postgresql/README.md create mode 100755 postgresql/defaults/main.yml create mode 100755 postgresql/tasks/main.yml create mode 100755 rsnapshot/README.md create mode 100755 rsnapshot/defaults/main.yml create mode 100755 rsnapshot/tasks/main.yml create mode 100755 rsnapshot/templates/exclude.txt.j2 create mode 100755 rsnapshot/templates/include.txt.j2 create mode 100755 rsnapshot/templates/rsnapshot.conf.j2 delete mode 100644 tasks/config.yml delete mode 100644 tasks/install.yml delete mode 100644 tasks/install_buildout.yml delete mode 100644 tasks/install_npm.yml delete mode 100644 tasks/install_pip.yml delete mode 100644 tasks/install_ssh.yml delete mode 100644 tasks/install_standard.yml delete mode 100644 tasks/main.yml delete mode 100644 tasks/postgresql.yml delete mode 100644 tasks/reportlab.yml delete mode 100644 tasks/service.yml delete mode 100644 tasks/wkhtmltox.yml delete mode 100644 templates/odoo-10.0-pip-requirements.txt delete mode 100644 templates/odoo-10.0.conf delete mode 100644 templates/odoo-10.0.conf.orig delete mode 100644 templates/odoo-10.0.init delete mode 100644 templates/odoo-11.0-pip-requirements.txt delete mode 100644 templates/odoo-11.0.conf delete mode 100644 templates/odoo-11.0.conf.orig delete mode 120000 templates/odoo-11.0.init delete mode 100644 templates/odoo-8.0-pip-requirements.txt delete mode 100644 templates/odoo-8.0.conf delete mode 100644 templates/odoo-8.0.init delete mode 100644 templates/odoo-9.0-pip-requirements.txt delete mode 100644 templates/odoo-9.0.conf delete mode 100644 templates/odoo-9.0.conf.orig delete mode 100644 templates/odoo-9.0.init delete mode 100644 templates/odoo-pip.init delete mode 100644 templates/odoo-pip.service delete mode 100644 templates/odoo-standard.service delete mode 100755 tests/install_test_env.sh delete mode 100644 tests/inventory delete mode 100755 tests/run.sh delete mode 100644 tests/test_buildout.yml delete mode 100644 tests/test_buildout_changed.yml delete mode 100644 tests/test_pip.yml delete mode 100644 tests/test_pip_changed.yml delete mode 100644 tests/test_standard.yml delete mode 100644 tests/test_standard_changed.yml delete mode 100755 tests/travis_lxd/create_container.sh delete mode 100755 tests/travis_lxd/fix_debian_jessie.sh delete mode 100755 tests/travis_lxd/install.sh delete mode 100644 tests/travis_lxd/lxd-debconf delete mode 100644 vars/Debian-8_Odoo-10.yml delete mode 100644 vars/Debian-8_Odoo-8.yml delete mode 100644 vars/Debian-8_Odoo-9.yml delete mode 100644 vars/Debian-9_Odoo-10.yml delete mode 100644 vars/Debian-9_Odoo-8.yml delete mode 100644 vars/Debian-9_Odoo-9.yml diff --git a/.directory b/.directory new file mode 100755 index 0000000..71584a2 --- /dev/null +++ b/.directory @@ -0,0 +1,6 @@ +[Dolphin] +Timestamp=2018,8,11,22,48,13 +Version=3 + +[Settings] +HiddenFilesShown=true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..523cd6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +odoo/files/id_rsa diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6ab6f94..0000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ ---- -sudo: required -dist: trusty - -env: - # Debian 8 (jessie) - # Odoo 8.0 - - IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 9.0 - - IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 10.0 - - IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Debian 9 (stretch) - # Odoo 8.0 - - IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 9.0 - - IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 10.0 - - IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 11.0 - - IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Ubuntu 14.04 (trusty) - # Odoo 8.0 - - IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 9.0 - - IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 10.0 - - IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Ubuntu 16.04 (xenial) - # Odoo 8.0 - - IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 9.0 - - IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 10.0 - - IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - # Odoo 11.0 - - IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5" - - IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5" - -install: - # Spawn a LXD container - - sudo ./tests/travis_lxd/install.sh - - sudo ./tests/travis_lxd/create_container.sh odoo-test - -script: - # Test the project into the container - - sudo lxc exec odoo-test -- sh -c "/opt/ansible-odoo/tests/run.sh" diff --git a/LICENCE.md b/LICENCE.md deleted file mode 100644 index 85c7c69..0000000 --- a/LICENCE.md +++ /dev/null @@ -1,636 +0,0 @@ -# GNU GENERAL PUBLIC LICENSE -Version 3, 29 June 2007 - -Copyright (C) 2007 [Free Software Foundation, Inc.](http://fsf.org/) - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -## Preamble - -The GNU General Public License is a free, copyleft license for software and -other kinds of works. - -The licenses for most software and other practical works are designed to take -away your freedom to share and change the works. By contrast, the GNU General -Public License is intended to guarantee your freedom to share and change all -versions of a program--to make sure it remains free software for all its users. -We, the Free Software Foundation, use the GNU General Public License for most -of our software; it applies also to any other work released this way by its -authors. You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom to -distribute copies of free software (and charge for them if you wish), that you -receive source code or can get it if you want it, that you can change the -software or use pieces of it in new free programs, and that you know you can do -these things. - -To protect your rights, we need to prevent others from denying you these rights -or asking you to surrender the rights. Therefore, you have certain -responsibilities if you distribute copies of the software, or if you modify it: -responsibilities to respect the freedom of others. - -For example, if you distribute copies of such a program, whether gratis or for -a fee, you must pass on to the recipients the same freedoms that you received. -You must make sure that they, too, receive or can get the source code. And you -must show them these terms so they know their rights. - -Developers that use the GNU GPL protect your rights with two steps: - - 1. assert copyright on the software, and - 2. offer you this License giving you legal permission to copy, distribute - and/or modify it. - -For the developers' and authors' protection, the GPL clearly explains that -there is no warranty for this free software. For both users' and authors' sake, -the GPL requires that modified versions be marked as changed, so that their -problems will not be attributed erroneously to authors of previous versions. - -Some devices are designed to deny users access to install or run modified -versions of the software inside them, although the manufacturer can do so. This -is fundamentally incompatible with the aim of protecting users' freedom to -change the software. The systematic pattern of such abuse occurs in the area of -products for individuals to use, which is precisely where it is most -unacceptable. Therefore, we have designed this version of the GPL to prohibit -the practice for those products. If such problems arise substantially in other -domains, we stand ready to extend this provision to those domains in future -versions of the GPL, as needed to protect the freedom of users. - -Finally, every program is threatened constantly by software patents. States -should not allow patents to restrict development and use of software on -general-purpose computers, but in those that do, we wish to avoid the special -danger that patents applied to a free program could make it effectively -proprietary. To prevent this, the GPL assures that patents cannot be used to -render the program non-free. - -The precise terms and conditions for copying, distribution and modification -follow. - -## TERMS AND CONDITIONS - -### 0. Definitions. - -*This License* refers to version 3 of the GNU General Public License. - -*Copyright* also means copyright-like laws that apply to other kinds of works, -such as semiconductor masks. - -*The Program* refers to any copyrightable work licensed under this License. -Each licensee is addressed as *you*. *Licensees* and *recipients* may be -individuals or organizations. - -To *modify* a work means to copy from or adapt all or part of the work in a -fashion requiring copyright permission, other than the making of an exact copy. -The resulting work is called a *modified version* of the earlier work or a work -*based on* the earlier work. - -A *covered work* means either the unmodified Program or a work based on the -Program. - -To *propagate* a work means to do anything with it that, without permission, -would make you directly or secondarily liable for infringement under applicable -copyright law, except executing it on a computer or modifying a private copy. -Propagation includes copying, distribution (with or without modification), -making available to the public, and in some countries other activities as well. - -To *convey* a work means any kind of propagation that enables other parties to -make or receive copies. Mere interaction with a user through a computer -network, with no transfer of a copy, is not conveying. - -An interactive user interface displays *Appropriate Legal Notices* to the -extent that it includes a convenient and prominently visible feature that - - 1. displays an appropriate copyright notice, and - 2. tells the user that there is no warranty for the work (except to the - extent that warranties are provided), that licensees may convey the work - under this License, and how to view a copy of this License. - -If the interface presents a list of user commands or options, such as a menu, a -prominent item in the list meets this criterion. - -### 1. Source Code. - -The *source code* for a work means the preferred form of the work for making -modifications to it. *Object code* means any non-source form of a work. - -A *Standard Interface* means an interface that either is an official standard -defined by a recognized standards body, or, in the case of interfaces specified -for a particular programming language, one that is widely used among developers -working in that language. - -The *System Libraries* of an executable work include anything, other than the -work as a whole, that (a) is included in the normal form of packaging a Major -Component, but which is not part of that Major Component, and (b) serves only -to enable use of the work with that Major Component, or to implement a Standard -Interface for which an implementation is available to the public in source code -form. A *Major Component*, in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system (if any) on -which the executable work runs, or a compiler used to produce the work, or an -object code interpreter used to run it. - -The *Corresponding Source* for a work in object code form means all the source -code needed to generate, install, and (for an executable work) run the object -code and to modify the work, including scripts to control those activities. -However, it does not include the work's System Libraries, or general-purpose -tools or generally available free programs which are used unmodified in -performing those activities but which are not part of the work. For example, -Corresponding Source includes interface definition files associated with source -files for the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, such as -by intimate data communication or control flow between those subprograms and -other parts of the work. - -The Corresponding Source need not include anything that users can regenerate -automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same work. - -### 2. Basic Permissions. - -All rights granted under this License are granted for the term of copyright on -the Program, and are irrevocable provided the stated conditions are met. This -License explicitly affirms your unlimited permission to run the unmodified -Program. The output from running a covered work is covered by this License only -if the output, given its content, constitutes a covered work. This License -acknowledges your rights of fair use or other equivalent, as provided by -copyright law. - -You may make, run and propagate covered works that you do not convey, without -conditions so long as your license otherwise remains in force. You may convey -covered works to others for the sole purpose of having them make modifications -exclusively for you, or provide you with facilities for running those works, -provided that you comply with the terms of this License in conveying all -material for which you do not control copyright. Those thus making or running -the covered works for you must do so exclusively on your behalf, under your -direction and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the -conditions stated below. Sublicensing is not allowed; section 10 makes it -unnecessary. - -### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - -No covered work shall be deemed part of an effective technological measure -under any applicable law fulfilling obligations under article 11 of the WIPO -copyright treaty adopted on 20 December 1996, or similar laws prohibiting or -restricting circumvention of such measures. - -When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention is -effected by exercising rights under this License with respect to the covered -work, and you disclaim any intention to limit operation or modification of the -work as a means of enforcing, against the work's users, your or third parties' -legal rights to forbid circumvention of technological measures. - -### 4. Conveying Verbatim Copies. - -You may convey verbatim copies of the Program's source code as you receive it, -in any medium, provided that you conspicuously and appropriately publish on -each copy an appropriate copyright notice; keep intact all notices stating that -this License and any non-permissive terms added in accord with section 7 apply -to the code; keep intact all notices of the absence of any warranty; and give -all recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, and you may -offer support or warranty protection for a fee. - -### 5. Conveying Modified Source Versions. - -You may convey a work based on the Program, or the modifications to produce it -from the Program, in the form of source code under the terms of section 4, -provided that you also meet all of these conditions: - - - a) The work must carry prominent notices stating that you modified it, and - giving a relevant date. - - b) The work must carry prominent notices stating that it is released under - this License and any conditions added under section 7. This requirement - modifies the requirement in section 4 to *keep intact all notices*. - - c) You must license the entire work, as a whole, under this License to - anyone who comes into possession of a copy. This License will therefore - apply, along with any applicable section 7 additional terms, to the whole - of the work, and all its parts, regardless of how they are packaged. This - License gives no permission to license the work in any other way, but it - does not invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your work need - not make them do so. - -A compilation of a covered work with other separate and independent works, -which are not by their nature extensions of the covered work, and which are not -combined with it such as to form a larger program, in or on a volume of a -storage or distribution medium, is called an *aggregate* if the compilation and -its resulting copyright are not used to limit the access or legal rights of the -compilation's users beyond what the individual works permit. Inclusion of a -covered work in an aggregate does not cause this License to apply to the other -parts of the aggregate. - -### 6. Conveying Non-Source Forms. - -You may convey a covered work in object code form under the terms of sections 4 -and 5, provided that you also convey the machine-readable Corresponding Source -under the terms of this License, in one of these ways: - - - a) Convey the object code in, or embodied in, a physical product (including - a physical distribution medium), accompanied by the Corresponding Source - fixed on a durable physical medium customarily used for software - interchange. - - b) Convey the object code in, or embodied in, a physical product (including - a physical distribution medium), accompanied by a written offer, valid for - at least three years and valid for as long as you offer spare parts or - customer support for that product model, to give anyone who possesses the - object code either - 1. a copy of the Corresponding Source for all the software in the product - that is covered by this License, on a durable physical medium - customarily used for software interchange, for a price no more than your - reasonable cost of physically performing this conveying of source, or - 2. access to copy the Corresponding Source from a network server at no - charge. - - c) Convey individual copies of the object code with a copy of the written - offer to provide the Corresponding Source. This alternative is allowed only - occasionally and noncommercially, and only if you received the object code - with such an offer, in accord with subsection 6b. - - d) Convey the object code by offering access from a designated place - (gratis or for a charge), and offer equivalent access to the Corresponding - Source in the same way through the same place at no further charge. You - need not require recipients to copy the Corresponding Source along with the - object code. If the place to copy the object code is a network server, the - Corresponding Source may be on a different server operated by you or a - third party) that supports equivalent copying facilities, provided you - maintain clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the Corresponding - Source, you remain obligated to ensure that it is available for as long as - needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided you - inform other peers where the object code and Corresponding Source of the - work are being offered to the general public at no charge under subsection - 6d. - -A separable portion of the object code, whose source code is excluded from the -Corresponding Source as a System Library, need not be included in conveying the -object code work. - -A *User Product* is either - - 1. a *consumer product*, which means any tangible personal property which is - normally used for personal, family, or household purposes, or - 2. anything designed or sold for incorporation into a dwelling. - -In determining whether a product is a consumer product, doubtful cases shall be -resolved in favor of coverage. For a particular product received by a -particular user, *normally used* refers to a typical or common use of that -class of product, regardless of the status of the particular user or of the way -in which the particular user actually uses, or expects or is expected to use, -the product. A product is a consumer product regardless of whether the product -has substantial commercial, industrial or non-consumer uses, unless such uses -represent the only significant mode of use of the product. - -*Installation Information* for a User Product means any methods, procedures, -authorization keys, or other information required to install and execute -modified versions of a covered work in that User Product from a modified -version of its Corresponding Source. The information must suffice to ensure -that the continued functioning of the modified object code is in no case -prevented or interfered with solely because modification has been made. - -If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as part of a -transaction in which the right of possession and use of the User Product is -transferred to the recipient in perpetuity or for a fixed term (regardless of -how the transaction is characterized), the Corresponding Source conveyed under -this section must be accompanied by the Installation Information. But this -requirement does not apply if neither you nor any third party retains the -ability to install modified object code on the User Product (for example, the -work has been installed in ROM). - -The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates for a -work that has been modified or installed by the recipient, or for the User -Product in which it has been modified or installed. Access to a network may be -denied when the modification itself materially and adversely affects the -operation of the network or violates the rules and protocols for communication -across the network. - -Corresponding Source conveyed, and Installation Information provided, in accord -with this section must be in a format that is publicly documented (and with an -implementation available to the public in source code form), and must require -no special password or key for unpacking, reading or copying. - -### 7. Additional Terms. - -*Additional permissions* are terms that supplement the terms of this License by -making exceptions from one or more of its conditions. Additional permissions -that are applicable to the entire Program shall be treated as though they were -included in this License, to the extent that they are valid under applicable -law. If additional permissions apply only to part of the Program, that part may -be used separately under those permissions, but the entire Program remains -governed by this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option remove any -additional permissions from that copy, or from any part of it. (Additional -permissions may be written to require their own removal in certain cases when -you modify the work.) You may place additional permissions on material, added -by you to a covered work, for which you have or can give appropriate copyright -permission. - -Notwithstanding any other provision of this License, for material you add to a -covered work, you may (if authorized by the copyright holders of that material) -supplement the terms of this License with terms: - - - a) Disclaiming warranty or limiting liability differently from the terms of - sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or author - attributions in that material or in the Appropriate Legal Notices displayed - by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in reasonable - ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or authors - of the material; or - - e) Declining to grant rights under trademark law for use of some trade - names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that material by - anyone who conveys the material (or modified versions of it) with - contractual assumptions of liability to the recipient, for any liability - that these contractual assumptions directly impose on those licensors and - authors. - -All other non-permissive additional terms are considered *further restrictions* -within the meaning of section 10. If the Program as you received it, or any -part of it, contains a notice stating that it is governed by this License along -with a term that is a further restriction, you may remove that term. If a -license document contains a further restriction but permits relicensing or -conveying under this License, you may add to a covered work material governed -by the terms of that license document, provided that the further restriction -does not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you must place, -in the relevant source files, a statement of the additional terms that apply to -those files, or a notice indicating where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the form of a -separately written license, or stated as exceptions; the above requirements -apply either way. - -### 8. Termination. - -You may not propagate or modify a covered work except as expressly provided -under this License. Any attempt otherwise to propagate or modify it is void, -and will automatically terminate your rights under this License (including any -patent licenses granted under the third paragraph of section 11). - -However, if you cease all violation of this License, then your license from a -particular copyright holder is reinstated - - - a) provisionally, unless and until the copyright holder explicitly and - finally terminates your license, and - - b) permanently, if the copyright holder fails to notify you of the - violation by some reasonable means prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is reinstated -permanently if the copyright holder notifies you of the violation by some -reasonable means, this is the first time you have received notice of violation -of this License (for any work) from that copyright holder, and you cure the -violation prior to 30 days after your receipt of the notice. - -Termination of your rights under this section does not terminate the licenses -of parties who have received copies or rights from you under this License. If -your rights have been terminated and not permanently reinstated, you do not -qualify to receive new licenses for the same material under section 10. - -### 9. Acceptance Not Required for Having Copies. - -You are not required to accept this License in order to receive or run a copy -of the Program. Ancillary propagation of a covered work occurring solely as a -consequence of using peer-to-peer transmission to receive a copy likewise does -not require acceptance. However, nothing other than this License grants you -permission to propagate or modify any covered work. These actions infringe -copyright if you do not accept this License. Therefore, by modifying or -propagating a covered work, you indicate your acceptance of this License to do -so. - -### 10. Automatic Licensing of Downstream Recipients. - -Each time you convey a covered work, the recipient automatically receives a -license from the original licensors, to run, modify and propagate that work, -subject to this License. You are not responsible for enforcing compliance by -third parties with this License. - -An *entity transaction* is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered work -results from an entity transaction, each party to that transaction who receives -a copy of the work also receives whatever licenses to the work the party's -predecessor in interest had or could give under the previous paragraph, plus a -right to possession of the Corresponding Source of the work from the -predecessor in interest, if the predecessor has it or can get it with -reasonable efforts. - -You may not impose any further restrictions on the exercise of the rights -granted or affirmed under this License. For example, you may not impose a -license fee, royalty, or other charge for exercise of rights granted under this -License, and you may not initiate litigation (including a cross-claim or -counterclaim in a lawsuit) alleging that any patent claim is infringed by -making, using, selling, offering for sale, or importing the Program or any -portion of it. - -### 11. Patents. - -A *contributor* is a copyright holder who authorizes use under this License of -the Program or a work on which the Program is based. The work thus licensed is -called the contributor's *contributor version*. - -A contributor's *essential patent claims* are all patent claims owned or -controlled by the contributor, whether already acquired or hereafter acquired, -that would be infringed by some manner, permitted by this License, of making, -using, or selling its contributor version, but do not include claims that would -be infringed only as a consequence of further modification of the contributor -version. For purposes of this definition, *control* includes the right to grant -patent sublicenses in a manner consistent with the requirements of this -License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free patent -license under the contributor's essential patent claims, to make, use, sell, -offer for sale, import and otherwise run, modify and propagate the contents of -its contributor version. - -In the following three paragraphs, a *patent license* is any express agreement -or commitment, however denominated, not to enforce a patent (such as an express -permission to practice a patent or covenant not to sue for patent -infringement). To *grant* such a patent license to a party means to make such -an agreement or commitment not to enforce a patent against the party. - -If you convey a covered work, knowingly relying on a patent license, and the -Corresponding Source of the work is not available for anyone to copy, free of -charge and under the terms of this License, through a publicly available -network server or other readily accessible means, then you must either - - 1. cause the Corresponding Source to be so available, or - 2. arrange to deprive yourself of the benefit of the patent license for this - particular work, or - 3. arrange, in a manner consistent with the requirements of this License, to - extend the patent license to downstream recipients. - -*Knowingly relying* means you have actual knowledge that, but for the patent -license, your conveying the covered work in a country, or your recipient's use -of the covered work in a country, would infringe one or more identifiable -patents in that country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or arrangement, you -convey, or propagate by procuring conveyance of, a covered work, and grant a -patent license to some of the parties receiving the covered work authorizing -them to use, propagate, modify or convey a specific copy of the covered work, -then the patent license you grant is automatically extended to all recipients -of the covered work and works based on it. - -A patent license is *discriminatory* if it does not include within the scope of -its coverage, prohibits the exercise of, or is conditioned on the non-exercise -of one or more of the rights that are specifically granted under this License. -You may not convey a covered work if you are a party to an arrangement with a -third party that is in the business of distributing software, under which you -make payment to the third party based on the extent of your activity of -conveying the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory patent -license - - - a) in connection with copies of the covered work conveyed by you (or copies - made from those copies), or - - b) primarily for and in connection with specific products or compilations - that contain the covered work, unless you entered into that arrangement, or - that patent license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting any implied -license or other defenses to infringement that may otherwise be available to -you under applicable patent law. - -### 12. No Surrender of Others' Freedom. - -If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not excuse -you from the conditions of this License. If you cannot convey a covered work so -as to satisfy simultaneously your obligations under this License and any other -pertinent obligations, then as a consequence you may not convey it at all. For -example, if you agree to terms that obligate you to collect a royalty for -further conveying from those to whom you convey the Program, the only way you -could satisfy both those terms and this License would be to refrain entirely -from conveying the Program. - -### 13. Use with the GNU Affero General Public License. - -Notwithstanding any other provision of this License, you have permission to -link or combine any covered work with a work licensed under version 3 of the -GNU Affero General Public License into a single combined work, and to convey -the resulting work. The terms of this License will continue to apply to the -part which is the covered work, but the special requirements of the GNU Affero -General Public License, section 13, concerning interaction through a network -will apply to the combination as such. - -### 14. Revised Versions of this License. - -The Free Software Foundation may publish revised and/or new versions of the GNU -General Public License from time to time. Such new versions will be similar in -spirit to the present version, but may differ in detail to address new problems -or concerns. - -Each version is given a distinguishing version number. If the Program specifies -that a certain numbered version of the GNU General Public License *or any later -version* applies to it, you have the option of following the terms and -conditions either of that numbered version or of any later version published by -the Free Software Foundation. If the Program does not specify a version number -of the GNU General Public License, you may choose any version ever published by -the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions of the -GNU General Public License can be used, that proxy's public statement of -acceptance of a version permanently authorizes you to choose that version for -the Program. - -Later license versions may give you additional or different permissions. -However, no additional obligations are imposed on any author or copyright -holder as a result of your choosing to follow a later version. - -### 15. Disclaimer of Warranty. - -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE -LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER -PARTIES PROVIDE THE PROGRAM *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE -QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE -DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR -CORRECTION. - -### 16. Limitation of Liability. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY -COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS -PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, -INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE -THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED -INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY -HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -### 17. Interpretation of Sections 15 and 16. - -If the disclaimer of warranty and limitation of liability provided above cannot -be given local legal effect according to their terms, reviewing courts shall -apply local law that most closely approximates an absolute waiver of all civil -liability in connection with the Program, unless a warranty or assumption of -liability accompanies a copy of the Program in return for a fee. - -## END OF TERMS AND CONDITIONS ### - -### How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible -use to the public, the best way to achieve this is to make it free software -which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach -them to the start of each source file to most effectively state the exclusion -of warranty; and each file should have at least the *copyright* line and a -pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - -If the program does terminal interaction, make it output a short notice like -this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w` and `show c` should show the appropriate -parts of the General Public License. Of course, your program's commands might -be different; for a GUI interface, you would use an *about box*. - -You should also get your employer (if you work as a programmer) or school, if -any, to sign a *copyright disclaimer* for the program, if necessary. For more -information on this, and how to apply and follow the GNU GPL, see -[http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). - -The GNU General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may consider -it more useful to permit linking proprietary applications with the library. If -this is what you want to do, use the GNU Lesser General Public License instead -of this License. But first, please read -[http://www.gnu.org/philosophy/why-not-lgpl.html](http://www.gnu.org/philosophy/why-not-lgpl.html). diff --git a/README.md b/README.md deleted file mode 100644 index f4e1db4..0000000 --- a/README.md +++ /dev/null @@ -1,239 +0,0 @@ -# Odoo [![Build Status](https://travis-ci.org/OCA/ansible-odoo.png)](https://travis-ci.org/OCA/ansible-odoo) - -Ansible role to install Odoo from a Git or Mercurial repository, or from pip, -and configure it. - -This role supports three types of installation: - -* **standard**: install the Odoo dependencies from APT repositories and the -Odoo project from a Git/Hg repository. Odoo is configured with Ansible options -(`odoo_config_*` ones). - -* **pip**: install Odoo and its dependencies (modules and Python packages) -from a pip requirements.txt file. Odoo is configured with Ansible options -(`odoo_config_*` ones). - -* **buildout**: build the Odoo project from a Git/Hg repository containing a -Buildout configuration file based on the -[anybox.recipe.odoo](https://pypi.python.org/pypi/anybox.recipe.odoo/) recipe. -Odoo and its dependencies are then installed and executed inside a Python -virtual environment. The configuration part is also managed by Buildout -(`odoo_config_*` options are not used excepting the `odoo_config_db_*` ones -for PostgreSQL related tasks). - -Minimum Ansible Version: 2.4 - -## Supported versions and systems - -| System / Odoo | 8.0 | 9.0 | 10.0 | 11.0 | -|---------------|-----|-----|------|------| -| Debian 8 | yes | yes | yes | - | -| Debian 9 | yes | yes | yes | yes | -| Ubuntu 14.04 | yes | yes | yes | - | -| Ubuntu 16.04 | yes | yes | yes | yes | - -## Example (Playbook) - -### odoo_install_type: standard (default) - -Standard installation (assuming that PostgreSQL is installed and running on -the same host): - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_version: 11.0 - odoo_config_admin_passwd: SuPerPassWorD -``` - -With the standard installation type you configure Odoo with the available -`odoo_config_*` options. - -Standard installation but with PostgreSQL installed on a remote host (and -available from your Ansible inventory): - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_version: 11.0 - odoo_config_admin_passwd: SuPerPassWorD - odoo_config_db_host: pg_server - odoo_config_db_user: odoo - odoo_config_db_passwd: PaSsWoRd -``` - -Standard installation from a personnal Git repository such as your repository -looks like this: - -```sh -REPO/ -├── server # could be a sub-repository of https://github.com/odoo/odoo -├── addons_oca_web # another sub-repository (https://github.com/OCA/web here) -├── addons_oca_connector # yet another sub-repository (https://github.com/OCA/connector) -└── addons # custom modules -``` - -Here we set some options required by the ``connector`` framework: - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_version: 11.0 - odoo_repo_type: git - odoo_repo_url: https://SERVER/REPO - odoo_repo_rev: master - odoo_repo_dest: "/home/{{ odoo_user }}/odoo" - odoo_init_env: - ODOO_CONNECTOR_CHANNELS: root:2 - odoo_config_admin_passwd: SuPerPassWorD - odoo_config_addons_path: - - "/home/{{ odoo_user }}/odoo/server/openerp/addons" - - "/home/{{ odoo_user }}/odoo/server/addons" - - "/home/{{ odoo_user }}/odoo/addons_oca_web" - - "/home/{{ odoo_user }}/odoo/addons_oca_connector" - - "/home/{{ odoo_user }}/odoo/addons" - odoo_config_server_wide_modules: web,web_kanban,connector - odoo_config_workers: 8 -``` - -### odoo_install_type: pip - -Pip installation (assuming that PostgreSQL is installed and running on -the same host). We need to ensure that the environment variable LC_ALL is used -if Odoo version 11 is to be used: - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_install_type: pip - odoo_version: 11.0 - odoo_pip_requirements_url: https://raw.githubusercontent.com/OCA/sample-oca-pip-requirements/11.0/requirements.txt - odoo_config_admin_passwd: SuPerPassWorD - environment: - LC_ALL: en_US.UTF-8 - -``` - - -### odoo_install_type: buildout - -With a Buildout installation type, Odoo is installed and configured directly -by Buildout: - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_install_type: buildout - odoo_version: 11.0 - odoo_repo_type: git - odoo_repo_url: https://github.com/osiell/odoo-buildout-example.git - odoo_repo_rev: "{{ odoo_version }}" - odoo_repo_dest: "/home/{{ odoo_user }}/odoo" -``` - -The same but with PostgreSQL installed on a remote host (and available from -your Ansible inventory): - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_install_type: buildout - odoo_version: 11.0 - odoo_repo_type: git - odoo_repo_url: https://github.com/osiell/odoo-buildout-example.git - odoo_repo_rev: "{{ odoo_version }}" - odoo_repo_dest: "/home/{{ odoo_user }}/odoo" - odoo_config_db_host: pg_server - odoo_config_db_user: odoo - odoo_config_db_passwd: PaSsWoRd -``` - -By default Ansible is looking for a `bootstrap.py` script and a `buildout.cfg` -file at the root of the cloned repository to call Buildout, but you can change -that to point to your own files. Assuming your repository looks like this: - -```sh -REPO/ -├── addons # custom modules -├── bin -│   └── bootstrap.py -├── builtout.cfg -├── builtout.dev.cfg -├── builtout.prod.cfg -└── builtout.test.cfg -``` - -We just set the relevant options to tell Ansible the files to use with the -`odoo_buildout_*` options: - -```yaml -- name: Odoo - hosts: odoo_server - become: yes - roles: - - role: odoo - odoo_install_type: buildout - odoo_version: 11.0 - odoo_repo_type: git - odoo_repo_url: https://SERVER/REPO - odoo_repo_rev: master - odoo_repo_dest: "/home/{{ odoo_user }}/odoo" - odoo_buildout_bootstrap_path: "/home/{{ odoo_user }}/odoo/bin/bootstrap.py" - odoo_buildout_config_path: "/home/{{ odoo_user }}/odoo/buildout.prod.cfg" -``` - -## Variables - -See the [defaults/main.yml](defaults/main.yml) file. - -## Bug Tracker - -Bugs are tracked on [GitHub Issues]( -https://github.com/OCA/ansible-odoo/issues). In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. - -## Credits - -### Contributors - -* Sébastien Alix -* Jordi Ballester Alomar - -Do not contact contributors directly about support or help with technical issues. - - -### Maintainer - -[![Odoo Community Association]( -https://odoo-community.org/logo.png)](https://odoo-community.org) - -This module is maintained by the OCA. - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. - -To contribute to this module, please visit https://odoo-community.org. - -## Licence - -This project is licensed under the terms of the GPLv3 license. diff --git a/barman/README.md b/barman/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/barman/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/barman/defaults/main.yml b/barman/defaults/main.yml new file mode 100755 index 0000000..c079787 --- /dev/null +++ b/barman/defaults/main.yml @@ -0,0 +1,14 @@ +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook/ +lxd_force: False +lxd_host_ip: 188.166.24.182 +lxd_host_user: odoo +barman_server_name: localhost +barman_server_ip: 10.10.10.20 +barman_home_directory: /mnt/volume-fra1-01/barman +postgres_home_directory: /var/lib/postgresql +odoo_config_db_port: 5432 +barman_superuser_user: bsuperuser +barman_superuser_password: password +barman_streaming_user: bstreaming +barman_streaming_password: password diff --git a/barman/tasks/main.yml b/barman/tasks/main.yml new file mode 100755 index 0000000..6bbbd43 --- /dev/null +++ b/barman/tasks/main.yml @@ -0,0 +1,283 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container IP. + become_user: root + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'" + register: container_ip + +- name: Get "{{ lxd_container_name }}" container DHCP gateway. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ip route |grep '^default' | awk '/eth0/' | cut -d' ' -f3" + register: container_gateway + +- name: Remove postgres@{{ lxd_container_name }} ssh configuration from barman@{{ rsnapshot_server_name }}:/root/.ssh/config if exest. + become_user: barman + delegate_to: "{{ barman_server_name }}" + replace: + path: "{{ barman_home_directory }}/.ssh/config" + regexp: "(?=Host {{ lxd_container_name }}\n)(((.+\n)+)\n*?)(?=\n)" + replace: "" + +- name: Create postgres@{{ lxd_container_name }} ssh configuration in barman@{{ barman_server_name }}:{{ barman_home_directory }}/.ssh/config. + become_user: barman + delegate_to: "{{ barman_server_name }}" + blockinfile: + dest: "{{ barman_home_directory }}/.ssh/config" + state: present + marker: "" + block: | + Host {{ lxd_container_name }} + ForwardAgent yes + Hostname {{ container_ip.stdout }} + Port 22 + User postgres + StrictHostKeyChecking no + ProxyCommand ssh {{ lxd_host_user }}@{{ lxd_host_ip }} nc %h 22 + +- name: Generate port string from "{{ lxd_container_name }}" container IP value. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}' | cut -d '.' -f4" + register: ssh_port_string + +- block: + - name: Set ssh port vriable. + set_fact: ssh_port="900{{ ssh_port_string.stdout }}" + when: ssh_port_string.stdout <= 9 + + - name: Set ssh port vriable. + set_fact: ssh_port="90{{ ssh_port_string.stdout }}" + when: ssh_port_string.stdout <= 99 + + - name: Set ssh port vriable. + set_fact: ssh_port="9{{ ssh_port_string.stdout }}" + when: ssh_port_string.stdout >= 100 + +- name: remove {{ ssh_port }} port forwarding role if exist in /etc/init.d/ssh_port_forwarding file. + become_user: root + delegate_to: "{{ barman_server_name }}" + lineinfile: + path: /etc/init.d/ssh_port_forwarding + state: absent + regexp: ^(su barman \-c "ssh \-fNT \-L {{ ssh_port }}\:) + +- name: Put {{ ssh_port }} port forwarding role in /etc/init.d/ssh_port_forwarding file. + become_user: root + delegate_to: "{{ barman_server_name }}" + lineinfile: + dest: "/etc/init.d/ssh_port_forwarding" + line: su barman -c "ssh -fNT -L {{ ssh_port }}:{{ container_ip.stdout }}:5432 {{ lxd_host_user }}@{{ lxd_host_ip }}" + +- name: Close {{ ssh_port }} port forwarding if opened. + become_user: barman + delegate_to: "{{ barman_server_name }}" + shell: | + kill $(ps aux | grep '[s]sh -fNT -L {{ ssh_port }}' | awk '{print $2}') + failed_when: false + +- name: Open {{ ssh_port }} port forwarding. + become_user: barman + delegate_to: "{{ barman_server_name }}" + shell: | + ssh -fNT -L {{ ssh_port }}:{{ container_ip.stdout }}:5432 {{ lxd_host_user }}@{{ lxd_host_ip }} + +# This block when barman_step is True +# This block to configure barman and PostgreSQL for continues backup +# kw-barman kw-check kw-set_var +- name: Check {{ postgres_home_directory }} if exists. + become_user: root + delegate_to: "{{ lxd_container_name }}" + stat: + path: "{{ postgres_home_directory }}" + register: postgres_home_dir + +# kw-ansible kw-message kw-barman +- debug: + msg: postgres home directory doesn't exist. Choose postgresql_step=True to install PostgreSQL, or correct {{ postgres_home_directory }} variable. + when: postgres_home_dir.stat.exists == False and postgresql_step == False + +# kw-ansible kw-barman +- meta: end_play + when: postgres_home_dir.stat.exists == False and postgresql_step == False + +- name: Ensure rsync is installed on {{ lxd_container_name }} + become_user: root + delegate_to: "{{ lxd_container_name }}" + apt: pkg=rsync state=present + +- name: Create Barman users on PostgreSQL server + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + postgresql_user: + name: "{{ item.name }}" + password: "{{ item.password }}" + role_attr_flags: "{{ item.role_attr_flags }}" +# port: "{{ postgresql_port|default(5432) }}" + with_items: + - { name: "{{ barman_superuser_user }}", password: "{{ barman_superuser_password }}", role_attr_flags: "SUPERUSER" } + - { name: "{{ barman_streaming_user }}", password: "{{ barman_streaming_password }}", role_attr_flags: "REPLICATION" } + +- name: Add rule in pg_hba.conf on primary server to allow streaming replication + become_user: root + delegate_to: "{{ lxd_container_name }}" + lineinfile: + dest: "/etc/postgresql/9.5/main/pg_hba.conf" + line: "host {{ item.database }} {{ item.user }} {{ container_gateway.stdout }}/32 md5" + with_items: + - { database: "postgres", user: "{{ barman_superuser_user }}" } + - { database: "replication", user: "{{ barman_streaming_user }}" } + +# kw-postgresql kw-barman kw-configure +- name: Configure postgres.conf on "{{ lxd_container_name }}" container to support Barman. + become_user: root + delegate_to: "{{ lxd_container_name }}" + template: + src: postgresql.conf.j2 + dest: /etc/postgresql/9.5/main/postgresql.conf + force: yes + owner: postgres + group: postgres + mode: 0644 + +# kw-postgresql kw-baramn kw-configure kw-create kw-ssh +- name: Create {{ postgres_home_directory }}/.ssh folder for postgres@{{ lxd_container_name }}. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + file: + path: "{{ postgres_home_directory }}/.ssh" + state: directory + mode: 0700 + owner: postgres + group: postgres + +# kw-postgresql kw-barman kw-set_var kw-ssh +- name: Get the barman@{{ barman_server_name }} ssh key. + become_user: barman + delegate_to: "{{ barman_server_name }}" + slurp: + src: '{{ barman_home_directory }}/.ssh/id_rsa.pub' + register: barman_ssh_key + +# kw-postgresql kw-barman kw-set_var kw-ssh +- name: Extract barman@{{ barman_server_name }} ssh key. + become_user: barman + delegate_to: "{{ barman_server_name }}" + set_fact: + barman_register_ssh: + comment: "barman@{{ barman_server_ip }}" + key: "{{ barman_ssh_key.content | b64decode | trim }}" + +# kw-postgresql kw-barman kw-create kw-ssh +- name: Deploy barman@{{ barman_server_name }} ssh key on postgres@{{ lxd_container_name }}. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + authorized_key: + user: 'postgres' + key: '{{ barman_register_ssh.key + " " + barman_register_ssh.comment }}' + state: 'present' + +# kw-postgresql kw-barman kw-create kw-ssh +- name: Touch Known_hosts for postgres@{{ lxd_container_name }}. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + file: + path: "{{ postgres_home_directory }}/.ssh/known_hosts" + state: touch + mode: 0600 + owner: postgres + group: postgres + +- name: remove {{ container_ip.stdout }} passwords if exist in {{ barman_home_directory }}/.pgpass file. + become_user: barman + delegate_to: "{{ barman_server_name }}" + lineinfile: + path: "{{ barman_home_directory }}/.pgpass" + state: absent + regexp: '^localhost\:{{ ssh_port }}\:' + +- name: Create .pgpass file entries to connect to PostgreSQL server + become_user: barman + delegate_to: "{{ barman_server_name }}" + lineinfile: + dest: "{{ barman_home_directory }}/.pgpass" + state: present + line: "{{ item }}" + with_items: + - "localhost:{{ ssh_port }}:postgres:{{ barman_superuser_user }}:{{ barman_superuser_password }}" + - "localhost:{{ ssh_port }}:*:{{ barman_streaming_user }}:{{ barman_superuser_password }}" + +# kw-postgresql kw-barman kw-configure +- name: Configure /etc/barmaan.d/{{ lxd_container_name }}.conf on "{{ barman_server_name }}" container. + become_user: root + delegate_to: "{{ barman_server_name }}" + template: + src: barman-server.conf.j2 + dest: /etc/barman.d/{{ lxd_container_name }}.conf + force: yes + owner: root + group: root + mode: 0644 + +# kw-postgresql kw-barman kw-configure kw-restart +- name: Restart PostgreSQL service. + become_user: root + delegate_to: "{{ lxd_container_name }}" + service: + name: postgresql + state: restarted + +# kw-rsnapshot kw-configure +- name: Configure "{{ lxd_container_name }}" backup in "{{ barman_server_name }}" cron. + become_user: barman + delegate_to: "{{ barman_server_name }}" + cron: + name: "{{ lxd_container_name }}" + minute: 13 + hour: 6 + job: "/usr/bin/barman backup {{ lxd_container_name }}" + +- name: Create the first backup. + become_user: barman + delegate_to: "{{ barman_server_name }}" + shell: | + barman switch-xlog --force --archive {{ lxd_container_name }} + barman backup {{ lxd_container_name }} diff --git a/barman/templates/barman-server.conf.j2 b/barman/templates/barman-server.conf.j2 new file mode 100755 index 0000000..7869247 --- /dev/null +++ b/barman/templates/barman-server.conf.j2 @@ -0,0 +1,15 @@ +[{{ lxd_container_name }}] +description = "{{ lxd_container_name }}" +archiver = on +streaming_archiver = on +backup_method = postgres +conninfo = host=localhost port={{ ssh_port }} user={{ barman_superuser_user }} dbname=postgres +streaming_conninfo = host=localhost port={{ ssh_port }} user={{ barman_streaming_user }} +ssh_command = ssh postgres@{{ container_ip.stdout }} +retention_policy_mode = auto +retention_policy = RECOVERY WINDOW OF 7 days +wal_retention_policy = main +streaming_backup_name = {{ lxd_container_name }}_streaming_backup +streaming_archiver_name = {{ lxd_container_name }}_receive_wal +immediate_checkpoint = false +minimum_redundancy=2 diff --git a/barman/templates/postgresql.conf.j2 b/barman/templates/postgresql.conf.j2 new file mode 100755 index 0000000..343b16f --- /dev/null +++ b/barman/templates/postgresql.conf.j2 @@ -0,0 +1,626 @@ +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- +# +# This file consists of lines of the form: +# +# name = value +# +# (The "=" is optional.) Whitespace may be used. Comments are introduced with +# "#" anywhere on a line. The complete list of parameter names and allowed +# values can be found in the PostgreSQL documentation. +# +# The commented-out settings shown in this file represent the default values. +# Re-commenting a setting is NOT sufficient to revert it to the default value; +# you need to reload the server. +# +# This file is read on server startup and when the server receives a SIGHUP +# signal. If you edit the file on a running system, you have to SIGHUP the +# server for the changes to take effect, or use "pg_ctl reload". Some +# parameters, which are marked below, require a server shutdown and restart to +# take effect. +# +# Any parameter can also be given as a command-line option to the server, e.g., +# "postgres -c log_connections=on". Some parameters can be changed at run time +# with the "SET" SQL command. +# +# Memory units: kB = kilobytes Time units: ms = milliseconds +# MB = megabytes s = seconds +# GB = gigabytes min = minutes +# TB = terabytes h = hours +# d = days + + +#------------------------------------------------------------------------------ +# FILE LOCATIONS +#------------------------------------------------------------------------------ + +# The default values of these variables are driven from the -D command-line +# option or PGDATA environment variable, represented here as ConfigDir. + +data_directory = '/var/lib/postgresql/9.5/main' # use data in another directory + # (change requires restart) +hba_file = '/etc/postgresql/9.5/main/pg_hba.conf' # host-based authentication file + # (change requires restart) +ident_file = '/etc/postgresql/9.5/main/pg_ident.conf' # ident configuration file + # (change requires restart) + +# If external_pid_file is not explicitly set, no extra PID file is written. +external_pid_file = '/var/run/postgresql/9.5-main.pid' # write an extra PID file + # (change requires restart) + + +#------------------------------------------------------------------------------ +# CONNECTIONS AND AUTHENTICATION +#------------------------------------------------------------------------------ + +# - Connection Settings - + +listen_addresses = '*' # what IP address(es) to listen on; + # comma-separated list of addresses; + # defaults to 'localhost'; use '*' for all + # (change requires restart) +port = {{ odoo_config_db_port }} # (change requires restart) +max_connections = 100 # (change requires restart) +#superuser_reserved_connections = 3 # (change requires restart) +unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories + # (change requires restart) +#unix_socket_group = '' # (change requires restart) +#unix_socket_permissions = 0777 # begin with 0 to use octal notation + # (change requires restart) +#bonjour = off # advertise server via Bonjour + # (change requires restart) +#bonjour_name = '' # defaults to the computer name + # (change requires restart) + +# - Security and Authentication - + +#authentication_timeout = 1min # 1s-600s +ssl = true # (change requires restart) +#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers + # (change requires restart) +#ssl_prefer_server_ciphers = on # (change requires restart) +#ssl_ecdh_curve = 'prime256v1' # (change requires restart) +ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart) +ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart) +#ssl_ca_file = '' # (change requires restart) +#ssl_crl_file = '' # (change requires restart) +#password_encryption = on +#db_user_namespace = off +#row_security = on + +# GSSAPI using Kerberos +#krb_server_keyfile = '' +#krb_caseins_users = off + +# - TCP Keepalives - +# see "man 7 tcp" for details + +#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; + # 0 selects the system default +#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; + # 0 selects the system default +#tcp_keepalives_count = 0 # TCP_KEEPCNT; + # 0 selects the system default + + +#------------------------------------------------------------------------------ +# RESOURCE USAGE (except WAL) +#------------------------------------------------------------------------------ + +# - Memory - + +shared_buffers = 128MB # min 128kB + # (change requires restart) +#huge_pages = try # on, off, or try + # (change requires restart) +#temp_buffers = 8MB # min 800kB +#max_prepared_transactions = 0 # zero disables the feature + # (change requires restart) +# Caution: it is not advisable to set max_prepared_transactions nonzero unless +# you actively intend to use prepared transactions. +#work_mem = 4MB # min 64kB +#maintenance_work_mem = 64MB # min 1MB +#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem +#max_stack_depth = 2MB # min 100kB +dynamic_shared_memory_type = posix # the default is the first option + # supported by the operating system: + # posix + # sysv + # windows + # mmap + # use none to disable dynamic shared memory + # (change requires restart) + +# - Disk - + +#temp_file_limit = -1 # limits per-session temp file space + # in kB, or -1 for no limit + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 + # (change requires restart) +#shared_preload_libraries = '' # (change requires restart) + +# - Cost-Based Vacuum Delay - + +#vacuum_cost_delay = 0 # 0-100 milliseconds +#vacuum_cost_page_hit = 1 # 0-10000 credits +#vacuum_cost_page_miss = 10 # 0-10000 credits +#vacuum_cost_page_dirty = 20 # 0-10000 credits +#vacuum_cost_limit = 200 # 1-10000 credits + +# - Background Writer - + +#bgwriter_delay = 200ms # 10-10000ms between rounds +#bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round +#bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round + +# - Asynchronous Behavior - + +#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching +#max_worker_processes = 8 + + +#------------------------------------------------------------------------------ +# WRITE AHEAD LOG +#------------------------------------------------------------------------------ + +# - Settings - + +wal_level = logical # minimal, archive, hot_standby, or logical + # (change requires restart) +#fsync = on # turns forced synchronization on or off +#synchronous_commit = on # synchronization level; + # off, local, remote_write, or on +#wal_sync_method = fsync # the default is the first option + # supported by the operating system: + # open_datasync + # fdatasync (default on Linux) + # fsync + # fsync_writethrough + # open_sync +#full_page_writes = on # recover from partial page writes +#wal_compression = off # enable compression of full-page writes +#wal_log_hints = off # also do full page writes of non-critical updates + # (change requires restart) +#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers + # (change requires restart) +#wal_writer_delay = 200ms # 1-10000 milliseconds + +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + +# - Checkpoints - + +#checkpoint_timeout = 5min # range 30s-1h +#max_wal_size = 1GB +#min_wal_size = 80MB +#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 +#checkpoint_warning = 30s # 0 disables + +# - Archiving - + +archive_mode = on # enables archiving; off, on, or always + # (change requires restart) +#archive_command = 'rsync -a %p barman@{{ barman_server_ip }}:/var/lib/barman/{{ lxd_container_name }}/incoming/%f' # command to use to archive a logfile segment +archive_command = '/bin/true' + # placeholders: %p = path of file to archive + # %f = file name only + # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' +#archive_timeout = 0 # force a logfile segment switch after this + # number of seconds; 0 disables + + +#------------------------------------------------------------------------------ +# REPLICATION +#------------------------------------------------------------------------------ + +# - Sending Server(s) - + +# Set these on the master and on any standby that will send replication data. + +max_wal_senders = 5 # max number of walsender processes + # (change requires restart) +#wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables +#wal_sender_timeout = 60s # in milliseconds; 0 disables + +max_replication_slots = 5 # max number of replication slots + # (change requires restart) +#track_commit_timestamp = off # collect timestamp of transaction commit + # (change requires restart) + +# - Master Server - + +# These settings are ignored on a standby server. + +#synchronous_standby_names = '' # standby servers that provide sync rep + # comma-separated list of application_name + # from standby(s); '*' = all +#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed + +# - Standby Servers - + +# These settings are ignored on a master server. + +#hot_standby = off # "on" allows queries during recovery + # (change requires restart) +#max_standby_archive_delay = 30s # max delay before canceling queries + # when reading WAL from archive; + # -1 allows indefinite delay +#max_standby_streaming_delay = 30s # max delay before canceling queries + # when reading streaming WAL; + # -1 allows indefinite delay +#wal_receiver_status_interval = 10s # send replies at least this often + # 0 disables +#hot_standby_feedback = off # send info from standby to prevent + # query conflicts +#wal_receiver_timeout = 60s # time that receiver waits for + # communication from master + # in milliseconds; 0 disables +#wal_retrieve_retry_interval = 5s # time to wait before retrying to + # retrieve WAL after a failed attempt + + +#------------------------------------------------------------------------------ +# QUERY TUNING +#------------------------------------------------------------------------------ + +# - Planner Method Configuration - + +#enable_bitmapscan = on +#enable_hashagg = on +#enable_hashjoin = on +#enable_indexscan = on +#enable_indexonlyscan = on +#enable_material = on +#enable_mergejoin = on +#enable_nestloop = on +#enable_seqscan = on +#enable_sort = on +#enable_tidscan = on + +# - Planner Cost Constants - + +#seq_page_cost = 1.0 # measured on an arbitrary scale +#random_page_cost = 4.0 # same scale as above +#cpu_tuple_cost = 0.01 # same scale as above +#cpu_index_tuple_cost = 0.005 # same scale as above +#cpu_operator_cost = 0.0025 # same scale as above +#effective_cache_size = 4GB + +# - Genetic Query Optimizer - + +#geqo = on +#geqo_threshold = 12 +#geqo_effort = 5 # range 1-10 +#geqo_pool_size = 0 # selects default based on effort +#geqo_generations = 0 # selects default based on effort +#geqo_selection_bias = 2.0 # range 1.5-2.0 +#geqo_seed = 0.0 # range 0.0-1.0 + +# - Other Planner Options - + +#default_statistics_target = 100 # range 1-10000 +#constraint_exclusion = partition # on, off, or partition +#cursor_tuple_fraction = 0.1 # range 0.0-1.0 +#from_collapse_limit = 8 +#join_collapse_limit = 8 # 1 disables collapsing of explicit + # JOIN clauses + + +#------------------------------------------------------------------------------ +# ERROR REPORTING AND LOGGING +#------------------------------------------------------------------------------ + +# - Where to Log - + +#log_destination = 'stderr' # Valid values are combinations of + # stderr, csvlog, syslog, and eventlog, + # depending on platform. csvlog + # requires logging_collector to be on. + +# This is used when logging to stderr: +#logging_collector = off # Enable capturing of stderr and csvlog + # into log files. Required to be on for + # csvlogs. + # (change requires restart) + +# These are only used if logging_collector is on: +#log_directory = 'pg_log' # directory where log files are written, + # can be absolute or relative to PGDATA +#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, + # can include strftime() escapes +#log_file_mode = 0600 # creation mode for log files, + # begin with 0 to use octal notation +#log_truncate_on_rotation = off # If on, an existing log file with the + # same name as the new log file will be + # truncated rather than appended to. + # But such truncation only occurs on + # time-driven rotation, not on restarts + # or size-driven rotation. Default is + # off, meaning append to existing files + # in all cases. +#log_rotation_age = 1d # Automatic rotation of logfiles will + # happen after that time. 0 disables. +#log_rotation_size = 10MB # Automatic rotation of logfiles will + # happen after that much log output. + # 0 disables. + +# These are relevant when logging to syslog: +#syslog_facility = 'LOCAL0' +#syslog_ident = 'postgres' + +# This is only relevant when logging to eventlog (win32): +# (change requires restart) +#event_source = 'PostgreSQL' + +# - When to Log - + +#client_min_messages = notice # values in order of decreasing detail: + # debug5 + # debug4 + # debug3 + # debug2 + # debug1 + # log + # notice + # warning + # error + +#log_min_messages = warning # values in order of decreasing detail: + # debug5 + # debug4 + # debug3 + # debug2 + # debug1 + # info + # notice + # warning + # error + # log + # fatal + # panic + +#log_min_error_statement = error # values in order of decreasing detail: + # debug5 + # debug4 + # debug3 + # debug2 + # debug1 + # info + # notice + # warning + # error + # log + # fatal + # panic (effectively off) + +#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements + # and their durations, > 0 logs only + # statements running at least this number + # of milliseconds + + +# - What to Log - + +#debug_print_parse = off +#debug_print_rewritten = off +#debug_print_plan = off +#debug_pretty_print = on +#log_checkpoints = off +#log_connections = off +#log_disconnections = off +#log_duration = off +#log_error_verbosity = default # terse, default, or verbose messages +#log_hostname = off +log_line_prefix = '%t [%p-%l] %q%u@%d ' # special values: + # %a = application name + # %u = user name + # %d = database name + # %r = remote host and port + # %h = remote host + # %p = process ID + # %t = timestamp without milliseconds + # %m = timestamp with milliseconds + # %i = command tag + # %e = SQL state + # %c = session ID + # %l = session line number + # %s = session start timestamp + # %v = virtual transaction ID + # %x = transaction ID (0 if none) + # %q = stop here in non-session + # processes + # %% = '%' + # e.g. '<%u%%%d> ' +#log_lock_waits = off # log lock waits >= deadlock_timeout +#log_statement = 'none' # none, ddl, mod, all +#log_replication_commands = off +#log_temp_files = -1 # log temporary files equal or larger + # than the specified size in kilobytes; + # -1 disables, 0 logs all temp files +log_timezone = 'UTC' + + +# - Process Title - + +#cluster_name = '' # added to process titles if nonempty + # (change requires restart) +#update_process_title = on + + +#------------------------------------------------------------------------------ +# RUNTIME STATISTICS +#------------------------------------------------------------------------------ + +# - Query/Index Statistics Collector - + +#track_activities = on +#track_counts = on +#track_io_timing = off +#track_functions = none # none, pl, all +#track_activity_query_size = 1024 # (change requires restart) +stats_temp_directory = '/var/run/postgresql/9.5-main.pg_stat_tmp' + + +# - Statistics Monitoring - + +#log_parser_stats = off +#log_planner_stats = off +#log_executor_stats = off +#log_statement_stats = off + + +#------------------------------------------------------------------------------ +# AUTOVACUUM PARAMETERS +#------------------------------------------------------------------------------ + +#autovacuum = on # Enable autovacuum subprocess? 'on' + # requires track_counts to also be on. +#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and + # their durations, > 0 logs only + # actions running at least this number + # of milliseconds. +#autovacuum_max_workers = 3 # max number of autovacuum subprocesses + # (change requires restart) +#autovacuum_naptime = 1min # time between autovacuum runs +#autovacuum_vacuum_threshold = 50 # min number of row updates before + # vacuum +#autovacuum_analyze_threshold = 50 # min number of row updates before + # analyze +#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum +#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze +#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum + # (change requires restart) +#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age + # before forced vacuum + # (change requires restart) +#autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for + # autovacuum, in milliseconds; + # -1 means use vacuum_cost_delay +#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for + # autovacuum, -1 means use + # vacuum_cost_limit + + +#------------------------------------------------------------------------------ +# CLIENT CONNECTION DEFAULTS +#------------------------------------------------------------------------------ + +# - Statement Behavior - + +#search_path = '"$user", public' # schema names +#default_tablespace = '' # a tablespace name, '' uses the default +#temp_tablespaces = '' # a list of tablespace names, '' uses + # only default tablespace +#check_function_bodies = on +#default_transaction_isolation = 'read committed' +#default_transaction_read_only = off +#default_transaction_deferrable = off +#session_replication_role = 'origin' +#statement_timeout = 0 # in milliseconds, 0 is disabled +#lock_timeout = 0 # in milliseconds, 0 is disabled +#vacuum_freeze_min_age = 50000000 +#vacuum_freeze_table_age = 150000000 +#vacuum_multixact_freeze_min_age = 5000000 +#vacuum_multixact_freeze_table_age = 150000000 +#bytea_output = 'hex' # hex, escape +#xmlbinary = 'base64' +#xmloption = 'content' +#gin_fuzzy_search_limit = 0 +#gin_pending_list_limit = 4MB + +# - Locale and Formatting - + +datestyle = 'iso, mdy' +#intervalstyle = 'postgres' +timezone = 'UTC' +#timezone_abbreviations = 'Default' # Select the set of available time zone + # abbreviations. Currently, there are + # Default + # Australia (historical usage) + # India + # You can create your own file in + # share/timezonesets/. +#extra_float_digits = 0 # min -15, max 3 +#client_encoding = sql_ascii # actually, defaults to database + # encoding + +# These settings are initialized by initdb, but they can be changed. +lc_messages = 'en_US.UTF-8' # locale for system error message + # strings +lc_monetary = 'en_US.UTF-8' # locale for monetary formatting +lc_numeric = 'en_US.UTF-8' # locale for number formatting +lc_time = 'en_US.UTF-8' # locale for time formatting + +# default configuration for text search +default_text_search_config = 'pg_catalog.english' + +# - Other Defaults - + +#dynamic_library_path = '$libdir' +#local_preload_libraries = '' +#session_preload_libraries = '' + + +#------------------------------------------------------------------------------ +# LOCK MANAGEMENT +#------------------------------------------------------------------------------ + +#deadlock_timeout = 1s +#max_locks_per_transaction = 64 # min 10 + # (change requires restart) +#max_pred_locks_per_transaction = 64 # min 10 + # (change requires restart) + + +#------------------------------------------------------------------------------ +# VERSION/PLATFORM COMPATIBILITY +#------------------------------------------------------------------------------ + +# - Previous PostgreSQL Versions - + +#array_nulls = on +#backslash_quote = safe_encoding # on, off, or safe_encoding +#default_with_oids = off +#escape_string_warning = on +#lo_compat_privileges = off +#operator_precedence_warning = off +#quote_all_identifiers = off +#sql_inheritance = on +#standard_conforming_strings = on +#synchronize_seqscans = on + +# - Other Platforms and Clients - + +#transform_null_equals = off + + +#------------------------------------------------------------------------------ +# ERROR HANDLING +#------------------------------------------------------------------------------ + +#exit_on_error = off # terminate session on any error? +#restart_after_crash = on # reinitialize after backend crash? + + +#------------------------------------------------------------------------------ +# CONFIG FILE INCLUDES +#------------------------------------------------------------------------------ + +# These options allow settings to be loaded from files other than the +# default postgresql.conf. + +#include_dir = 'conf.d' # include files ending in '.conf' from + # directory 'conf.d' +#include_if_exists = 'exists.conf' # include file only if it exists +#include = 'special.conf' # include file + + +#------------------------------------------------------------------------------ +# CUSTOMIZED OPTIONS +#------------------------------------------------------------------------------ + +# Add settings for extensions here diff --git a/defaults/main.yml b/defaults/main.yml deleted file mode 100644 index c270c5c..0000000 --- a/defaults/main.yml +++ /dev/null @@ -1,142 +0,0 @@ -ansible_ssh_pipelining: true - -odoo_install_type: standard # standard, buildout -odoo_version: 11.0 -odoo_service: odoo -odoo_user: odoo -odoo_user_passwd: "*" # http://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module -odoo_user_update_password: always -odoo_user_shell: /bin/bash -odoo_user_system: False -odoo_init: True -odoo_init_env: {} - #VAR1: value1 - #VAR2: value2 -odoo_logdir: "/var/log/{{ odoo_user }}" -odoo_logfile: "{{ ansible_service_mgr != 'systemd' and ('/'.join([odoo_logdir, odoo_service]) + '.log') or ''}}" -odoo_workdir: "/home/{{ odoo_user }}/odoo" -odoo_rootdir: "{{ odoo_install_type == 'buildout' and '/home/'+odoo_user+'/odoo/parts/odoo' or '/home/'+odoo_user+'/odoo/server' }}" - -# Project repository to deploy -odoo_repo_type: git # git or hg -odoo_repo_url: "{{ odoo_install_type == 'buildout' and 'https://github.com/osiell/odoo-buildout-example.git' or 'https://github.com/odoo/odoo.git' }}" -odoo_repo_dest: "{{ odoo_install_type == 'buildout' and odoo_workdir or odoo_rootdir }}" -odoo_repo_rev: "{{ odoo_version }}" -odoo_repo_update: True # Update the working copy or not. This option is - # ignored on the first run (a checkout of the working - # copy is always processed on the given revision) - # WARNING: uncommited changes will be discarded! -odoo_repo_depth: 1 # Set to 0 to clone the full history (slower) - # (this option is not supported with hg) - -# Third party programs options -odoo_reportlab_font_url: http://www.reportlab.com/ftp/pfbfer.zip - -# Tasks related to PostgreSQL -odoo_postgresql_set_user: True -odoo_postgresql_user_role_attr: CREATEDB,NOSUPERUSER -odoo_postgresql_extensions: - - unaccent - -# Standard installation/configuration options (odoo_install_type == 'standard') -odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf" -odoo_force_config: True -odoo_config_addons_path: - - "/home/{{ odoo_user }}/odoo/server/{{ (odoo_version | int) < 10 and 'openerp' or 'odoo' }}/addons" - - "/home/{{ odoo_user }}/odoo/server/addons" -odoo_config_admin_passwd: admin -odoo_config_auto_reload: False -odoo_config_csv_internal_sep: ',' -odoo_config_data_dir: "/home/{{ odoo_user }}/.local/share/Odoo" -odoo_config_db_host: False -odoo_config_db_host_user: "{{ ansible_user }}" -odoo_config_db_maxconn: 64 -odoo_config_db_name: False -odoo_config_db_passwd: False -odoo_config_db_port: False -odoo_config_db_sslmode: prefer # >= 11.0 -odoo_config_db_template: template1 -odoo_config_db_user: "{{ odoo_user }}" -odoo_config_dbfilter: '.*' -odoo_config_debug_mode: False # <= 9.0 -odoo_config_pidfile: None -odoo_config_proxy_mode: False -odoo_config_email_from: False -odoo_config_geoip_database: /usr/share/GeoIP/GeoLiteCity.dat -odoo_config_http_enable: True # >= 11.0 -odoo_config_http_interface: '' # >= 11.0 -odoo_config_http_port: 8069 # >= 11.0 -odoo_config_limit_memory_hard: 2684354560 -odoo_config_limit_memory_soft: 2147483648 -odoo_config_limit_time_cpu: 60 -odoo_config_limit_time_real: 120 -odoo_config_limit_time_real_cron: -1 # >= 10.0 -odoo_config_list_db: True -odoo_config_log_db: False -odoo_config_log_level: info -odoo_config_logfile: None -odoo_config_logrotate: False -odoo_config_longpolling_port: 8072 -odoo_config_osv_memory_age_limit: 1.0 -odoo_config_osv_memory_count_limit: False -odoo_config_max_cron_threads: 2 -odoo_config_secure_cert_file: server.cert -odoo_config_secure_pkey_file: server.pkey -odoo_config_server_wide_modules: None -odoo_config_smtp_password: False -odoo_config_smtp_port: 25 -odoo_config_smtp_server: localhost -odoo_config_smtp_ssl: False -odoo_config_smtp_user: False -odoo_config_syslog: False -odoo_config_timezone: False -odoo_config_translate_modules: "['all']" -odoo_config_unaccent: False -odoo_config_without_demo: False -odoo_config_workers: 0 -odoo_config_xmlrpc: True # <= 10.0 -odoo_config_xmlrpc_interface: '' # <= 10.0 -odoo_config_xmlrpc_port: 8069 # <= 10.0 -odoo_config_xmlrpcs: True # <= 8.0 -odoo_config_xmlrpcs_interface: '' # <= 8.0 -odoo_config_xmlrpcs_port: 8071 # <= 8.0 -# Custom configuration options -odoo_config_custom: {} - #your_option1: value1 - #your_option2: value2 - -# Pip installation options (odoo_install_type == 'pip') -odoo_pip_venv_path: "{{ odoo_workdir }}/sandbox" -odoo_pip_requirements_url: "file:///home/{{ odoo_user }}/requirements.txt" -odoo_pip_odoo_bin_path: "{{ odoo_pip_venv_path }}/bin/{{ (odoo_version | int) < 10 and 'odoo.py' or 'odoo' }}" - -# Buildout installation options (odoo_install_type == 'buildout') -odoo_buildout_version: 2.10.0 -odoo_buildout_venv_path: "{{ odoo_workdir }}/sandbox" -odoo_buildout_bootstrap_path: "{{ odoo_workdir }}/bootstrap.py" -odoo_buildout_bootstrap_cmd: "{{ odoo_buildout_venv_path }}/bin/python {{ odoo_buildout_bootstrap_path }} -c {{ odoo_buildout_config_path }} --buildout-version {{ odoo_buildout_version }}" -odoo_buildout_bin_path: "{{ odoo_workdir }}/bin/buildout" -odoo_buildout_config_path: "{{ odoo_workdir }}/buildout.cfg" -odoo_buildout_odoo_bin_path: "{{ odoo_workdir }}/bin/start_odoo" -odoo_buildout_extra_dependencies: [] # Extra Debian packages required - # to run your Buildout recipe - -# SSH configuration options -odoo_user_ssh_dir: "/home/{{ odoo_user }}/.ssh" -odoo_user_ssh_key: {} - # This option set only a pair of private key (/!\ without password /!\) - # and public key saved as 'id_rsa{.pub}' (default path) allowing version - # control like Git to clone repositories without configuring the ssh-agent. - # Example: - # odoo_user_ssh_key: - # priv: "path/to/private_key" - # pub: "path/to/public_key.pub" -odoo_user_ssh_known_hosts_file: "{{ odoo_user_ssh_dir }}/known_hosts" -odoo_user_ssh_known_hosts: [] - # This option add hosts fingerprint to the 'known_hosts' file. Example: - # odoo_user_ssh_known_hosts: - # - bitbucket.org - # -# FIXME: 'odoo_user_sshkeys' option (and the underlying task) needs refactoring -# to handle the state of SSH public keys (present/absent). -odoo_user_sshkeys: "" # ./path/to/public_keys/* diff --git a/files/bootstrap.py b/files/bootstrap.py deleted file mode 100644 index 1f59b21..0000000 --- a/files/bootstrap.py +++ /dev/null @@ -1,210 +0,0 @@ -############################################################################## -# -# Copyright (c) 2006 Zope Foundation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""Bootstrap a buildout-based project - -Simply run this script in a directory containing a buildout.cfg. -The script accepts buildout command-line options, so you can -use the -c option to specify an alternate configuration file. -""" - -import os -import shutil -import sys -import tempfile - -from optparse import OptionParser - -__version__ = '2015-07-01' -# See zc.buildout's changelog if this version is up to date. - -tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') - -usage = '''\ -[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] - -Bootstraps a buildout-based project. - -Simply run this script in a directory containing a buildout.cfg, using the -Python that you want bin/buildout to use. - -Note that by using --find-links to point to local resources, you can keep -this script from going over the network. -''' - -parser = OptionParser(usage=usage) -parser.add_option("--version", - action="store_true", default=False, - help=("Return bootstrap.py version.")) -parser.add_option("-t", "--accept-buildout-test-releases", - dest='accept_buildout_test_releases', - action="store_true", default=False, - help=("Normally, if you do not specify a --buildout-version, " - "the bootstrap script and buildout gets the newest " - "*final* versions of zc.buildout and its recipes and " - "extensions for you. If you use this flag, " - "bootstrap and buildout will get the newest releases " - "even if they are alphas or betas.")) -parser.add_option("-c", "--config-file", - help=("Specify the path to the buildout configuration " - "file to be used.")) -parser.add_option("-f", "--find-links", - help=("Specify a URL to search for buildout releases")) -parser.add_option("--allow-site-packages", - action="store_true", default=False, - help=("Let bootstrap.py use existing site packages")) -parser.add_option("--buildout-version", - help="Use a specific zc.buildout version") -parser.add_option("--setuptools-version", - help="Use a specific setuptools version") -parser.add_option("--setuptools-to-dir", - help=("Allow for re-use of existing directory of " - "setuptools versions")) - -options, args = parser.parse_args() -if options.version: - print("bootstrap.py version %s" % __version__) - sys.exit(0) - - -###################################################################### -# load/install setuptools - -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen - -ez = {} -if os.path.exists('ez_setup.py'): - exec(open('ez_setup.py').read(), ez) -else: - exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) - -if not options.allow_site_packages: - # ez_setup imports site, which adds site packages - # this will remove them from the path to ensure that incompatible versions - # of setuptools are not in the path - import site - # inside a virtualenv, there is no 'getsitepackages'. - # We can't remove these reliably - if hasattr(site, 'getsitepackages'): - for sitepackage_path in site.getsitepackages(): - # Strip all site-packages directories from sys.path that - # are not sys.prefix; this is because on Windows - # sys.prefix is a site-package directory. - if sitepackage_path != sys.prefix: - sys.path[:] = [x for x in sys.path - if sitepackage_path not in x] - -setup_args = dict(to_dir=tmpeggs, download_delay=0) - -if options.setuptools_version is not None: - setup_args['version'] = options.setuptools_version -if options.setuptools_to_dir is not None: - setup_args['to_dir'] = options.setuptools_to_dir - -ez['use_setuptools'](**setup_args) -import setuptools -import pkg_resources - -# This does not (always?) update the default working set. We will -# do it. -for path in sys.path: - if path not in pkg_resources.working_set.entries: - pkg_resources.working_set.add_entry(path) - -###################################################################### -# Install buildout - -ws = pkg_resources.working_set - -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - -# Fix sys.path here as easy_install.pth added before PYTHONPATH -cmd = [sys.executable, '-c', - 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + - 'from setuptools.command.easy_install import main; main()', - '-mZqNxd', tmpeggs] - -find_links = os.environ.get( - 'bootstrap-testing-find-links', - options.find_links or - ('http://downloads.buildout.org/' - if options.accept_buildout_test_releases else None) - ) -if find_links: - cmd.extend(['-f', find_links]) - -requirement = 'zc.buildout' -version = options.buildout_version -if version is None and not options.accept_buildout_test_releases: - # Figure out the most recent final version of zc.buildout. - import setuptools.package_index - _final_parts = '*final-', '*final' - - def _final_version(parsed_version): - try: - return not parsed_version.is_prerelease - except AttributeError: - # Older setuptools - for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): - return False - return True - - index = setuptools.package_index.PackageIndex( - search_path=[setuptools_path]) - if find_links: - index.add_find_links((find_links,)) - req = pkg_resources.Requirement.parse(requirement) - if index.obtain(req) is not None: - best = [] - bestv = None - for dist in index[req.project_name]: - distv = dist.parsed_version - if _final_version(distv): - if bestv is None or distv > bestv: - best = [dist] - bestv = distv - elif distv == bestv: - best.append(dist) - if best: - best.sort() - version = best[-1].version -if version: - requirement = '=='.join((requirement, version)) -cmd.append(requirement) - -import subprocess -if subprocess.call(cmd) != 0: - raise Exception( - "Failed to execute command:\n%s" % repr(cmd)[1:-1]) - -###################################################################### -# Import and run buildout - -ws.add_entry(tmpeggs) -ws.require(requirement) -import zc.buildout.buildout - -if not [a for a in args if '=' not in a]: - args.append('bootstrap') - -# if -c was provided, we push it back into args for buildout' main function -if options.config_file is not None: - args[0:0] = ['-c', options.config_file] - -zc.buildout.buildout.main(args) -shutil.rmtree(tmpeggs) diff --git a/lxd/README.md b/lxd/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/lxd/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/lxd/defaults/main.yml b/lxd/defaults/main.yml new file mode 100755 index 0000000..51fc991 --- /dev/null +++ b/lxd/defaults/main.yml @@ -0,0 +1,17 @@ +lxd_host_user: odoo #Your account on LXD host server +lxd_host_name: testserver +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook +lxd_force: False +container_nameservers: " " #The DNS address in your network +odoo_user: ubuntu #Your account to install odoo in odoo host +odoo_user_passwd: 11223344 #We use this variable just when we create a new "Odoo System User". # http://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module +odoo_user_update_password: always #We use this variable just when we choose odoo_user!="ubuntu". +odoo_user_shell: /bin/bash #We use this variable to set system user password just when we choose odoo_user!="ubuntu". +odoo_user_system: False #We use this variable just when we choose odoo_user!="ubuntu". and it affects just a new user, not an existing user. + + + + + + diff --git a/lxd/tasks/main.yml b/lxd/tasks/main.yml new file mode 100755 index 0000000..fbddcbb --- /dev/null +++ b/lxd/tasks/main.yml @@ -0,0 +1,174 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# This block when lxd_step is True +# This block create LXD container with basic specifications. +# kw-create +- name: Create "{{ lxd_container_name }}" container. + delegate_to: "{{ lxd_host_name }}" + lxd_container: + name: "{{ lxd_container_name }}" + state: started + source: + type: image + mode: pull + server: https://images.linuxcontainers.org + protocol: lxd + alias: ubuntu/xenial/amd64 + profiles: ["default"] + wait_for_ipv4_addresses: true + timeout: 600 + +# kw-ansible +- name: Add new "{{ lxd_container_name }}" name in hosts file. + lineinfile: + dest: hosts +# line: "{{ lxd_container_name }} ansible_connection=lxd" + line: "{{ lxd_container_name }} ansible_connection=lxd ansible_host={{ lxd_host_name }}:{{ lxd_container_name }}" + +# kw-ansible +- name: Refresh hosts + meta: refresh_inventory + +# kw-check kw-set_var +- name: Check python is installed in "{{ lxd_container_name }}" container. + delegate_to: "{{ lxd_container_name }}" + connection: lxd + raw: dpkg -s python + register: python_install_check + failed_when: python_install_check.rc not in [0, 1] + changed_when: false + +# kw-install-pkg +- name: Install python in "{{ lxd_container_name }}" container. + delegate_to: "{{ lxd_container_name }}" + raw: apt-get install -y python + when: python_install_check.rc == 1 + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container DHCP IP. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'" + register: container_ip + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container DHCP Broadcast. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f3 | awk '{print $1}'" + register: container_broadcast + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container DHCP Netmask. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f4 | awk '{print $1}'" + register: container_netmask + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container DHCP gateway. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ip route |grep '^default' | awk '/eth0/' | cut -d' ' -f3" + register: container_gateway + +# kw-system kw-networking kw-configure kw-remove +- name: Remove /etc/network/interfaces. + delegate_to: "{{ lxd_container_name }}" + file: + path: /etc/network/interfaces + state: absent + +# kw-system kw-networking kw-configure kw-create +- name: Touch /etc/network/interfaces. + delegate_to: "{{ lxd_container_name }}" + file: + path: /etc/network/interfaces + state: touch + +# kw-system kw-networking kw-configure +- name: Config /etc/network/interfaces. + delegate_to: "{{ lxd_container_name }}" + lineinfile: + dest: /etc/network/interfaces + line: "{{ item }}" + with_items: + - auto lo + - iface lo inet loopback + - " " + - auto eth0 + - iface eth0 inet static + - "address {{ container_ip.stdout }}" + - "netmask {{ container_netmask.stdout }}" + - "broadcast {{ container_broadcast.stdout }}" + - "gateway {{ container_gateway.stdout }}" + - "dns-nameservers {{ container_gateway.stdout }} {{ container_nameservers }}" + +# kw-system kw-networking kw-configure kw-restart +- name: Restart networking service. + delegate_to: "{{ lxd_container_name }}" + shell: | + ifdown eth0 + ifup eth0 + service networking restart + +# kw-system kw-user kw-create +- name: Add "{{ odoo_user }}" system user into "{{ lxd_container_name }}" container OS. + delegate_to: "{{ lxd_container_name }}" + user: + name: "{{ odoo_user }}" + shell: "{{ odoo_user_shell }}" + password: "{{ odoo_user_passwd }}" + update_password: "{{ odoo_user_update_password }}" + system: "{{ odoo_user_system }}" + tags: + - odoo_user + when: odoo_user != "ubuntu" + +# kw-user kw-create kw-ssh +- name: Ensure /home/{{ odoo_user }}/.ssh folder is exists. + delegate_to: "{{ lxd_container_name }}" + file: + path: /home/{{ odoo_user }}/.ssh + state: directory + mode: 0700 + owner: "{{ odoo_user }}" + group: "{{ odoo_user }}" + +# kw-install-pkg +- name: Ensure openssh-server is installed. + delegate_to: "{{ lxd_container_name }}" + apt: pkg=openssh-server state=present diff --git a/meta/main.yml b/meta/main.yml deleted file mode 100644 index 785c63e..0000000 --- a/meta/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -galaxy_info: - author: Sébastien Alix - description: Ansible role to install Odoo from a Git or Mercurial repository, and configure it. - company: OSIELL - license: GPLv3 - min_ansible_version: 2.4 - platforms: - - name: Debian - versions: - - jessie - - stretch - - name: Ubuntu - versions: - - trusty - - xenial - categories: - - web -dependencies: [] diff --git a/msmtp/README.md b/msmtp/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/msmtp/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/msmtp/defaults/main.yml b/msmtp/defaults/main.yml new file mode 100755 index 0000000..f2c7948 --- /dev/null +++ b/msmtp/defaults/main.yml @@ -0,0 +1,20 @@ +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook/ +lxd_force: False +odoo_config_db_name: odoodatabase +odoo_config_db_user: ubuntu +odoo_config_db_passwd: password +odoo_version: 10.0 +odoo_user: ubuntu +nginx_subdomain: test +nginx_domain: sunflowerodoo.nl +rsnapshot_server_name: localhost +rsnapshot_backup_dir: /mnt/volume-fra1-01/backup/lxd/rsnapshot +barman_server_name: localhost +recipent_email: astheotherway@gmail.com + + + + + + diff --git a/msmtp/tasks/main.yml b/msmtp/tasks/main.yml new file mode 100755 index 0000000..4add640 --- /dev/null +++ b/msmtp/tasks/main.yml @@ -0,0 +1,104 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +- name: Get "{{ lxd_container_name }}" container IP. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'" + register: container_ip + +- name: Ensure sendmail is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=sendmail state=present + +- name: Ensure mailutils is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=mailutils state=present + +- name: Ensure bsd-mailx is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=bsd-mailx state=present + +- name: Ensure s-nail is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=s-nail state=present + +- name: Ensure heirloom-mailx is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=heirloom-mailx state=present + +- name: Ensure msmtp is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=msmtp state=present + +- name: Ensure msmtp-mta is installed + delegate_to: "{{ lxd_container_name }}" + apt: pkg=msmtp-mta state=present + +- name: Config /etc/msmtprc . + delegate_to: "{{ lxd_container_name }}" + template: + src: msmtp.j2 + dest: /etc/msmtprc + force: yes + owner: root + group: root + mode: 0644 + +- name: Config /etc/mail.rc . + delegate_to: "{{ lxd_container_name }}" + lineinfile: + dest: /etc/mail.rc + line: "{{ item }}" + with_items: + - set sendmail="/usr/bin/msmtp" + - set from="helpdesk@sunflowerweb.nl" + +- name: Create mail body file . + delegate_to: "{{ lxd_container_name }}" + template: + src: mail.j2 + dest: /root/mail + force: yes + owner: root + group: root + mode: 0600 + +- name: send mail. + delegate_to: "{{ lxd_container_name }}" + shell: cat /root/mail | mail -s {{ nginx_subdomain }}.{{ nginx_domain }} {{ recipent_email }} diff --git a/msmtp/templates/mail.j2 b/msmtp/templates/mail.j2 new file mode 100755 index 0000000..65bd62c --- /dev/null +++ b/msmtp/templates/mail.j2 @@ -0,0 +1,22 @@ +Hi +We create {{ lxd_container_name }} container with this specifications: +Container IP: {{ container_ip.stdout }} +PostgreSQL database name: {{ odoo_config_db_name }} +PostgreSQL user grant to database: {{ odoo_config_db_user }} +postgreSQL password: {{ odoo_config_db_passwd }} +Odoo version: {{ odoo_version }} +Odoo user: {{ odoo_user }} +Odoo work directory: /home/{{ odoo_user }}/odoo +Link to access Odoo in this container: https://{{ nginx_subdomain }}.{{ nginx_domain }} +The backup of this container on {{ rsnapshot_server_name }} server +The path of packup on {{ rsnapshot_server_name }} server: {{ rsnapshot_backup_dir }}/{{ lxd_container_name }} +The continues backup of PostgreSQL on {{ barman_server_name }} server +Regards + + + + + + + + diff --git a/msmtp/templates/msmtp.j2 b/msmtp/templates/msmtp.j2 new file mode 100755 index 0000000..60e8161 --- /dev/null +++ b/msmtp/templates/msmtp.j2 @@ -0,0 +1,23 @@ +# From this line to the first 'account X' line are settings for all accounts +defaults +auth on +tls on +# This is where the TLS CERTs reside +tls_trust_file /etc/ssl/certs/ca-certificates.crt +logfile /var/mail/log/msmtp.log +# With tls_starttls on it will be a clear session and then upgrade to TLS +# using the STARTTLS command. If set to 'off' then the whole session is +# encrypted inside a TLS session (SMTPS) +tls_starttls off +# This is the log file - comment it out to stop it collecting +# Authentication must be used for sending +# Each account will use a different method +## Account ## +account axc +host mail.axc.nl +port 465 +user helpdesk@sunflowerweb.nl +from helpdesk@sunflowerweb.nl +password {{ mail_password }} + +account default: axc diff --git a/nginx/README.md b/nginx/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/nginx/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/nginx/defaults/main.yml b/nginx/defaults/main.yml new file mode 100755 index 0000000..136c0ca --- /dev/null +++ b/nginx/defaults/main.yml @@ -0,0 +1,13 @@ +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook +nginx_container_name: nginx-proxy +lxd_force: False +odoo_config_xmlrpc_port: 8069 #The XMLRPC port of odoo +odoo_config_longpolling_port: 8072 #The longpolling port of odoo +nginx_domain: sunflowerodoo.nl #The parent domain of LXD container URL +nginx_subdomain: "{{ lxd_container_name }}" #The subdomain to access odoo through NGINX domain + + + + + diff --git a/nginx/tasks/main.yml b/nginx/tasks/main.yml new file mode 100755 index 0000000..2d1776a --- /dev/null +++ b/nginx/tasks/main.yml @@ -0,0 +1,100 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container IP. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'" + register: container_ip + +# This block when nginx_step is True +# This block to configure NGINX proxy +# kw-nginx kw-check kw-set_var +- name: Check /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} file if exists. + delegate_to: "{{ nginx_container_name }}" + stat: + path: /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} + register: stat_result + +# kw-nginx kw-set_var +- name: Generate random string. + delegate_to: "{{ nginx_container_name }}" + shell: head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '' + register: random_string + when: stat_result.stat.exists + +# kw-nginx kw-configure kw-remove kw-create +- name: Rename /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} to /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ random_string.stdout }} + delegate_to: "{{ nginx_container_name }}" + shell: mv /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ random_string.stdout }} + when: stat_result.stat.exists + +# kw-nginx kw-configure kw-create +- name: Touch /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} + delegate_to: "{{ nginx_container_name }}" + file: + path: /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} + state: touch + +- name: Create Letsencrypt certifecate to {{ nginx_subdomain }}.{{ nginx_domain }} . + delegate_to: "{{ nginx_container_name }}" + shell: certbot certonly --nginx -d {{ nginx_subdomain }}.{{ nginx_domain }} --force-renewal + +- name: Config /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} . + delegate_to: "{{ nginx_container_name }}" + template: + src: nginx-proxy.j2 + dest: /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} + force: yes + owner: root + group: root + mode: 0644 + +# kw-nginx kw-configure +- name: Link /etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }} to /etc/nginx/sites-enabled/{{ nginx_subdomain }}.{{ nginx_domain }} + delegate_to: "{{ nginx_container_name }}" + file: + src: "/etc/nginx/sites-available/{{ nginx_subdomain }}.{{ nginx_domain }}" + dest: "/etc/nginx/sites-enabled/{{ nginx_subdomain }}.{{ nginx_domain }}" + state: link + +# kw-system kw-nginx kw-configure +- name: Reload NGINX service. + delegate_to: "{{ nginx_container_name }}" + shell: nginx -t && nginx -s reload diff --git a/nginx/templates/nginx-proxy.j2 b/nginx/templates/nginx-proxy.j2 new file mode 100755 index 0000000..3da947d --- /dev/null +++ b/nginx/templates/nginx-proxy.j2 @@ -0,0 +1,56 @@ +server { + if ($host = {{ nginx_subdomain }}.{{ nginx_domain }}) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + + server_name {{ nginx_subdomain }}.{{ nginx_domain }}; + location / { + return 301 https://$host$request_uri; + } + + +} + +server { + listen 443; + server_name {{ nginx_subdomain }}.{{ nginx_domain }}; + + ssl on; + ssl_certificate /etc/letsencrypt/live/{{ nginx_subdomain }}.{{ nginx_domain }}/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/{{ nginx_subdomain }}.{{ nginx_domain }}/privkey.pem; # managed by Certbot +# add_header Strict-Transport-Security max-age=2592000; + + # increase file upload size + client_max_body_size 200M; + + # increase timeouts to avoid nginx gateway timeout for long requests + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + # add headers + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ container_ip.stdout }}:{{ odoo_config_xmlrpc_port }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + } + + location /longpolling { + proxy_pass http://{{ container_ip.stdout }}:{{ odoo_config_longpolling_port }}; + } + + +} + diff --git a/odoo/README.md b/odoo/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/odoo/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/odoo/defaults/main.yml b/odoo/defaults/main.yml new file mode 100755 index 0000000..357e914 --- /dev/null +++ b/odoo/defaults/main.yml @@ -0,0 +1,50 @@ +host_user: odoo #Your account on LXD host server +lxd_container_name: test #The name you giv to a new LXD container +lxd_force: False +odoo_user: ubuntu #Your account to install odoo in odoo host +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook +odoo_version: 8.0 # +sunflower_repo_url: "git@github.com:sunflowerit/custom-installations.git" #The repository site link of odoo +branch: 9.0-custom-standard #The branch of Sunflower repository if you choose it +github_account: anonymous #Your account in github site +github_account_name: anonymous #Your account name in github site +odoo_config_admin_passwd: admin #Admin password for odoo +odoo_config_db_host: localhost #The name of server is hosts odoo database +odoo_config_db_name: odoodatabase #The name of odoo database +odoo_config_db_user: "{{ odoo_user }}" #The odoo account in PostgreSQL +odoo_config_db_passwd: password #The passowrd of odoo account in PostgreSQL +odoo_config_db_user_righs: "NOCREATEDB,NOSUPERUSER" #The right what odoo account in Postgresql have +odoo_config_db_port: 5432 #The port of database into PostgreSQL +odoo_config_xmlrpc_port: 8069 #The XMLRPC port of odoo +odoo_config_longpolling_port: 8072 #The longpolling port of odoo +odoo_service: odoo #The name of odoo service in odoo OS host +odoo_buildout_version: 2.11.4 #The version of Buildout script +odoo_workdir: "/home/{{ odoo_user }}/odoo" #The folder where odoo files tree +odoo_buildout_bin_path: "{{ odoo_workdir }}/bin/buildout" #The path where Buildout script +odoo_buildout_bootstrap_path: "{{ odoo_workdir }}/bootstrap.py" #The path where Bootstrap script +odoo_buildout_bootstrap_cmd: "/usr/bin/python {{ odoo_buildout_bootstrap_path }} -c {{ odoo_buildout_config_path }} --buildout-version {{ odoo_buildout_version }}" #The command to run bootstrap script +buildout_config_file: odoo{{ odoo_version | int }}-standard.cfg #The name of buildout config file +odoo_buildout_config_path: "{{ odoo_workdir }}/local.cfg" #The path of buildout config file +odoo_logdir: "/var/log/{{ odoo_user }}" #The folder of odoo log files +odoo_logfile: "{{ ansible_service_mgr != 'systemd' and ('/'.join([odoo_logdir, odoo_service]) + '.log') or ''}}" #The odoo log file +run_bootstrap: True #True to run bootstrap into buildout step, false to ignore that +app_before_buildout: True #True to install recruitments pkg before run buildout, False to ignore that +run_buildout: True #True to run buildout into buildout step, False to ignore that +odoo_buildout_odoo_bin_path: "{{ odoo_workdir }}/bin/start_odoo" #The path of script to start odoo +app_after_buildout: True #True to install recruitments pkg after run buildout, False to ignore that +odoo_reportlab_font_url: http://www.reportlab.com/ftp/pfbfer.zip # Third party programs options +odoo_init: True # To create init file to config odoo service +odoo_config_server_wide_modules: None #We use this varible just when we odoo_init == True +odoo_init_env: {} #We use this varible just when we odoo_init == True + #VAR1: value1 #We use this varible just when we odoo_init == True + #VAR2: value2 #We use this varible just when we odoo_init == True +odoo_user_passwd: 11223344 #We use this variable just when we create a new "Odoo System User". # http://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module +odoo_user_update_password: always #We use this variable just when we choose odoo_user!="ubuntu". +odoo_user_shell: /bin/bash #We use this variable to set system user password just when we choose odoo_user!="ubuntu". +odoo_user_system: False #We use this variable just when we choose odoo_user!="ubuntu". and it affects just a new user, not an existing user. + + + + + + diff --git a/odoo/files/odoo_cfg_files/base3.cfg b/odoo/files/odoo_cfg_files/base3.cfg new file mode 100755 index 0000000..c2b8afd --- /dev/null +++ b/odoo/files/odoo_cfg_files/base3.cfg @@ -0,0 +1,81 @@ +[buildout] +parts = odoo +find-links = + http://github.com/aeroo/aeroolib/tarball/master#egg=aeroolib +versions = versions +extensions = gp.vcsdevelop +vcs-extend-develop = + git+https://github.com/anybox/anybox.recipe.odoo#egg=anybox.recipe.odoo +include-site-packages = true +allowed-eggs-from-site-packages = lxml +vcs-update = True +newest = false + +[odoo] +version = git http://github.com/OCA/OCB.git odoo 10.0 depth=1 +release = 10.0 +git-warn-sha-pins = False +recipe = anybox.recipe.odoo:server +eggs = + gevent + inouk.recipe.odoo_cmd + docutils + ebaysdk + jcconv + psycogreen + Python-Chart + python-dateutil + six + Werkzeug + wsgiref + XlsxWriter +#pyparsing + +[versions] +babel= 2.3.4 +decorator= 4.0.10 +docutils= 0.12 +feedparser= 5.2.1 +gevent= 1.1.2 +jinja2= 2.8 +lxml= 3.6.4 +mako= 1.0.4 +mock= 2.0.0 +ofxparse= 0.15 +passlib= 1.6.5 +pillow= 3.4.2 +psutil= 4.4.2 +psycopg2= 2.6.2 +python-chart= 1.39 +pydot= 1.2.3 +#pyparsing= 2.1.10 +pypdf= 1.13 +python-dateutil= 2.5.3 +python-openid= 2.2.5 +pytz= 2016.7 +pyyaml= 3.12 +qrcode= 5.3 +reportlab= 3.3.0 +requests= 2.11.1 +vatnumber= 1.2 +vobject= 0.9.3 +werkzeug= 0.11.11 +xlsxwriter = 0.9.6 +xlwt= 1.1.2 + +# stuff +six=1.10.0 +wsgiref=0.1.2 + +# Dependency of previous lib +pbr = 2.0.0 +psycogreen = 1.0 +beautifulsoup4 = 4.5.3 +funcsigs = 1.0.2 +gevent = 1.1.2 +markupsafe = 1.0 +zc.buildout = 2.11.4 +python-stdnum = 1.5 +greenlet = 0.4.12 +zc.recipe.egg = 2.0.3 + diff --git a/odoo/files/odoo_cfg_files/buildout.cfg b/odoo/files/odoo_cfg_files/buildout.cfg new file mode 100755 index 0000000..5225e73 --- /dev/null +++ b/odoo/files/odoo_cfg_files/buildout.cfg @@ -0,0 +1,44 @@ +[buildout] +extends = base3.cfg + + +[odoo] +eggs += + pyserial + pypdf2 + unicodecsv + pysftp + + +addons += +# git git@github.com:OCA/server-tools.git parts/server-tools 10.0 +# git git@github.com:sunflowerit/custom-installations.git parts/custom-piano 10.0-custom-pianoservice + git git@github.com:sunflowerit/freshfilter-odoo-modules.git parts/custom-freshfilter 10.0 +# git git@github.com:OCA/social.git parts/social 10.0 + git git@github.com:OCA/partner-contact.git parts/partner-contact 10.0 + git git@github.com:OCA/l10n-netherlands.git parts/l10n-netherlands 10.0 +# git git@github.com:it-projects-llc/pos-addons parts/pos-addons 10.0 + +merges += + git git@github.com:sunflowerit/freshfilter-odoo-modules.git parts/custom-freshfilter 10.0-307-Porting-of-customer-asset-inspection-portal-freshfilter + +#git git@github.com:sunflowerit/freshfilter-community-modules.git parts/custom-freshfilter 10.0-porting-sale-production-links + + +# This directive will nuke local changes, but without it, a branch with merges +# cannot be updated if the main branch has progressed. This will break +# rebuilds. Use this in production and testing, not in development. +vcs-clear-retry = True + +options.db_maxconn = 64 +options.workers = 2 +options.max_cron_threads = 1 +options.xmlrpc = True +options.xmlrpcs = False +options.netrpc = False +options.limit_time_cpu = 36000 +options.limit_time_real = 72000 +options.log_handler = :INFO,werkzeug:CRITICAL,openerp.service.server:INFO +options.log_level = info +options.lang = nl_NL + diff --git a/handlers/main.yml b/odoo/handlers/main.yml old mode 100644 new mode 100755 similarity index 54% rename from handlers/main.yml rename to odoo/handlers/main.yml index a4f508a..aa046fa --- a/handlers/main.yml +++ b/odoo/handlers/main.yml @@ -1,12 +1,14 @@ --- -- name: Restart Odoo +- name: Restart {{ odoo_service }} + delegate_to: "{{ lxd_container_name }}" service: name: "{{ odoo_service }}" state: restarted - when: odoo_init == True + when: odoo_init - name: Reload Systemd + delegate_to: "{{ lxd_container_name }}" systemd: daemon-reload: yes when: ansible_service_mgr == 'systemd' diff --git a/odoo/tasks/main.yml b/odoo/tasks/main.yml new file mode 100755 index 0000000..615deed --- /dev/null +++ b/odoo/tasks/main.yml @@ -0,0 +1,412 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-odoo kw-set_var +- name: Set variables depending on the platform and the version of Odoo. + include_vars: "{{ item }}" + with_first_found: + - "../vars/Odoo-{{ odoo_version | int }}.yml" + +#This block when app_before_buildout and buildout_step are True +# This block to install some important packages for odoo +- block: +# kw-odoo kw-install-pkg + - name: Install required tools. + delegate_to: "{{ lxd_container_name }}" + apt: pkg={{ item }} + state=present + update_cache={{ odoo_apt_update_cache }} + cache_valid_time={{ odoo_apt_cache_valid_time }} + with_items: "{{ odoo_required_tools }}" + +# kw-odoo kw-postgresql kw-instaall-pkg + - name: Ensure nl_NL.UTF-8 locale exists. + delegate_to: "{{ lxd_container_name }}" + locale_gen: + name: nl_NL.UTF-8 + state: present + +# kw-odoo kw-install-pkg install-pip + - name: install latest pip. + delegate_to: "{{ lxd_container_name }}" + easy_install: + name: pip + state: present + +# kw-odoo kw-install-pkg + - name: Install build dependencies. + delegate_to: "{{ lxd_container_name }}" + apt: pkg={{ item }} + state=present + update_cache={{ odoo_apt_update_cache }} + cache_valid_time={{ odoo_apt_cache_valid_time }} + with_items: "{{ odoo_buildout_build_dependencies }}" + when: app_before_buildout == True + +# This block when buildout_step is True +# This block to clone our Odoo from https://github.com/sunflowerit/custom-installations +- block: +# kw-odoo kw-ssh + - name: copy id_rsa file that added on sunflower github account befor. + delegate_to: "{{ lxd_container_name }}" + copy: + src: id_rsa + dest: /home/{{ odoo_user }}/.ssh/ + force: yes + owner: "{{ odoo_user }}" + group: "{{ odoo_user }}" + mode: 0600 + +# kw-odoo kw-create kw-ssh + - name: Touch Known_hosts for {{ odoo_user }}@{{ lxd_container_name }}. + delegate_to: "{{ lxd_container_name }}" + file: + path: /home/{{ odoo_user }}/.ssh/known_hosts + state: touch + mode: 0755 + owner: "{{ odoo_user }}" + group: "{{ odoo_user }}" + +# kw-odoo kw-create kw-ssh + - name: Add github key to known_hosts on {{ odoo_user }}@{{ lxd_container_name }}. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + shell: | + ssh-keygen -F github.com || ssh-keyscan github.com >> /home/{{ odoo_user }}/.ssh/known_hosts + +# kw-odoo kw-configure kw-ssh + - name: Config "{{ github_account_name }}" github account for {{ odoo_user }}@{{ lxd_container_name }}. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + shell: | + git config --global user.email "{{ github_account }}" + git config --global user.name "{{ github_account_name }}" + +# kw-odoo kw-create + - name: Clone project from {{ sunflower_repo_url }}. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + git: + clone: yes + force: yes + repo: "{{ sunflower_repo_url }}" + version: "{{ branch }}" + dest: "{{ odoo_workdir }}" + notify: Restart {{ odoo_service }} + +# This block when buildout_step is True +# This block to put and tune Odoo config files into container +- block: +# kw-odoo kw-configure kw-remove + - name: Remove {{ odoo_workdir }}/local.cfg if exist. + delegate_to: "{{ lxd_container_name }}" + file: + path: "{{ odoo_workdir }}/local.cfg" + state: absent + +# kw-odoo kw-configure kw-create + - name: Touch {{ odoo_workdir }}/local.cfg. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + file: + path: "{{ odoo_workdir }}/local.cfg" + state: touch + force: yes + +# kw-odoo kw-configure kw-create + - name: Config {{ odoo_workdir }}/local.cfg. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + lineinfile: + dest: "{{ odoo_workdir }}/local.cfg" + line: "{{ item }}" + with_items: + - "[buildout]" + - "extends = {{ buildout_config_file }}" + - " " + - "[odoo]" + - "options.admin_passwd = {{ odoo_config_admin_passwd }}" + - "options.db_host = {{ odoo_config_db_host }}" + - "options.db_name = {{ odoo_config_db_name }}" + - "options.db_port = {{ odoo_config_db_port }}" + - "options.db_user = {{ odoo_config_db_user }}" + - "options.db_password = {{ odoo_config_db_passwd }}" + - "options.xmlrpc_port = {{ odoo_config_xmlrpc_port }}" + - "options.longpolling_port = {{ odoo_config_longpolling_port }}" + +# kw-odoo kw-configure kw-create + - name: Copy roles/odoo/files/odoo_cfg_files/* to {{ odoo_workdir }}/ + delegate_to: "{{ lxd_container_name }}" + copy: + src: "{{ item }}" + dest: /home/{{ odoo_user }}/odoo/ + force: yes + owner: "{{ odoo_user }}" + group: "{{ odoo_user }}" + mode: 0644 + with_fileglob: + - odoo_cfg_files/* + +# - name: copy id_rsa file that added on sunflower github account befor. +# delegate_to: "{{ lxd_container_name }}" +# copy: +# src: id_rsa +# dest: /home/{{ odoo_user }}/.ssh/ +# force: yes +# owner: "{{ odoo_user }}" +# group: "{{ odoo_user }}" +# mode: 0600 + + +# This block when buildout_step is true +# This block to run buildout and install odoo +- block: +# kw-odoo kw-install-odoo + - name: 'Install buildout (run: "{{ odoo_buildout_bootstrap_cmd }}").' + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + command: "{{ odoo_buildout_bootstrap_cmd }}" + args: + creates: "{{ odoo_buildout_bin_path }}" + when: run_bootstrap + +# kw-odoo kw-configure + - name: Stop "{{ odoo_service }}" service. + delegate_to: "{{ lxd_container_name }}" + service: + name: "{{ odoo_service }}" + state: stop + when: run_buildout == True and run_bootstrap == False + failed_when: false + +# kw-odoo kw-install-pip + - name: Installing setuptools python library using Ansible pip module. + delegate_to: "{{ lxd_container_name }}" + pip: + name: setuptools + version: 38.1.0 + when: run_buildout + +# kw-odoo kw-create kw-install-odoo + - name: Download the pip requirements file for odoo {{ odoo_version }}. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + get_url: url="https://raw.githubusercontent.com/odoo/odoo/{{ odoo_version }}/requirements.txt" dest="{{ odoo_workdir }}/requirements.txt" + when: run_buildout + +# kw-odoo kw-install-odoo kw-install-pip + - name: Install requirements for odoo {{ odoo_version }}. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + pip: + requirements: "{{ odoo_workdir }}/requirements.txt" + state: present + notify: Restart {{ odoo_service }} + failed_when: false + when: run_buildout + +# kw-odoo kw-install-odoo + - name: 'Run: "{{ odoo_buildout_bin_path }} -c {{ odoo_buildout_config_path }}"' + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + command: "{{ odoo_buildout_bin_path }} -c {{ odoo_buildout_config_path }}" + changed_when: False + when: run_buildout + +# This block when app_after_buildout and buildout_step are True and odoo_version >= 9 +# This block to install NodeJS +- block: +# kw-system kw-odoo kw-configure kw-install-pkg + - name: Configure NodeJS APT repository signing key. + delegate_to: "{{ lxd_container_name }}" + apt_key: + url: "{{ item.url }}" + state: "{{ item.state }}" + with_items: "{{ odoo_nodejs_apt_keys | default([]) }}" + +# kw-system kw-odoo kw-configure kw-install-pkg + - name: Configure NodeJS APT repository. + delegate_to: "{{ lxd_container_name }}" + apt_repository: + repo: "{{ item.repo }}" + state: "{{ item.state }}" + with_items: "{{ odoo_nodejs_apt_repositories | default([]) }}" + +# kw-odoo kw-install-pkg + - name: Install NodeJS. + delegate_to: "{{ lxd_container_name }}" + apt: pkg={{ odoo_nodejs_apt_package }} + state=present + update_cache=yes + +# kw-odoo kw-install-pkg + - name: Install Odoo dependencies (npm). + delegate_to: "{{ lxd_container_name }}" + npm: name={{ item.name }} + version={{ item.version }} + global=yes + with_items: "{{ odoo_npm_packages | default([]) }}" + when: (odoo_version | int) >= 9 and app_after_buildout == True + +# This block when app_after_buildout and buildout_step are True +# This block to install wkhtmltox +- block: +# kw-odoo kw-set_var + - name: Detect Debian architecture (i386 or amd64). + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + set_fact: odoo_debian_arch={{ '64' in ansible_architecture and 'amd64' or 'i386' }} + +# kw-odoo kw-create kw-install-pkg + - name: Download wkhtmltox. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + get_url: url={{ item }} + dest={{ odoo_wkhtmltox_dest }} + with_items: "{{ odoo_wkhtmltox_urls }}" + ignore_errors: True + when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False + failed_when: false + +# kw-odoo kw-check kw-install-pkg + - name: Check wkhtmltox package. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + stat: path={{ odoo_wkhtmltox_dest }} + register: odoo_wkhtmltox_pkg + +# kw-odoo kw-install-pkg + - name: Install wkhtmltox dependencies. + delegate_to: "{{ lxd_container_name }}" + apt: pkg={{ item }} + with_items: "{{ odoo_wkhtmltox_depends }}" + when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists + +# kw-odoo kw-install-pkg + - name: Install wkhtmltox (Debian package). + delegate_to: "{{ lxd_container_name }}" + apt: + deb: "{{ odoo_wkhtmltox_dest }}" + force: yes + when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists and odoo_wkhtmltox_pkg.stat.mimetype in ['application/x-debian-package', 'application/vnd.debian.binary-package'] + +# kw-odoo kw-install-pkg + - name: Install wkhtmltox (generic package). + delegate_to: "{{ lxd_container_name }}" + unarchive: + remote_src: yes + src: "{{ odoo_wkhtmltox_dest }}" + dest: /usr/local + extra_opts: "--strip-components=1" + creates: /usr/local/bin/wkhtmltopdf + when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists and odoo_wkhtmltox_pkg.stat.mimetype == 'application/x-xz' + when: app_after_buildout + +# This block when app_after_buildout and buildout_step are True +# This block to install ReportLab +- block: +# kw-odoo kw-create kw-install-pkg + - name: Download the ReportLab barcode fonts. + delegate_to: "{{ lxd_container_name }}" + get_url: url="{{ odoo_reportlab_font_url }}" + dest="/opt/pfbfer.zip" + +# kw-odoo kw-create kw-install-pkg + - name: Create the font directory. + become_user: "{{ odoo_user }}" + delegate_to: "{{ lxd_container_name }}" + file: path="/home/{{ odoo_user }}/fonts" state=directory + +# kw-odoo kw-install + - name: Install unzip. + delegate_to: "{{ lxd_container_name }}" + apt: name=unzip state=present + +# kw-odoo kw-create kw-install + - name: Unzip the ReportLab fonts. + delegate_to: "{{ lxd_container_name }}" + unarchive: src="/opt/pfbfer.zip" + dest="/home/{{ odoo_user }}/fonts" + owner={{ odoo_user }} + group={{ odoo_user }} + mode="u=rwX,go=rX" + copy=No + creates="/home/{{ odoo_user }}/fonts/_abi____.pfb" + when: app_after_buildout + +# This block when buildout_step is True +# This step to configire odoo service +- block: +# kw-system kw-odoo kw-configure + - name: Generate "{{ odoo_service }}" init script (buildout) + delegate_to: "{{ lxd_container_name }}" + template: src=odoo-buildout.init dest=/etc/init.d/{{ odoo_service }} + owner=root group=root mode=0755 + force=yes + backup=yes + when: ansible_service_mgr != 'systemd' + notify: Restart {{ odoo_service }} + +# kw-system kw-odoo kw-configure + - name: Generate systemd "{{ odoo_service }}" service (buildout) + delegate_to: "{{ lxd_container_name }}" + template: + src=odoo-buildout.service + dest=/etc/systemd/system/{{ odoo_service }}.service + owner=root group=root mode=0755 + force=yes + backup=yes + when: ansible_service_mgr == 'systemd' + notify: + - Reload Systemd + - Restart {{ odoo_service }} + +# kw-system kw-odoo kw-configure + - name: Enable "{{ odoo_service }}" service. + delegate_to: "{{ lxd_container_name }}" + service: name={{ odoo_service }} enabled=yes state=started + when: odoo_init + +# kw-system kw-odoo kw-configure + - name: Disable "{{ odoo_service }}" service. + delegate_to: "{{ lxd_container_name }}" + service: name={{ odoo_service }} enabled=no state=stopped + when: not odoo_init + + diff --git a/templates/odoo-buildout.init b/odoo/templates/odoo-buildout.init old mode 100644 new mode 100755 similarity index 100% rename from templates/odoo-buildout.init rename to odoo/templates/odoo-buildout.init diff --git a/templates/odoo-buildout.service b/odoo/templates/odoo-buildout.service old mode 100644 new mode 100755 similarity index 100% rename from templates/odoo-buildout.service rename to odoo/templates/odoo-buildout.service diff --git a/vars/Ubuntu-14_Odoo-10.yml b/odoo/vars/Odoo-10.yml old mode 100644 new mode 100755 similarity index 69% rename from vars/Ubuntu-14_Odoo-10.yml rename to odoo/vars/Odoo-10.yml index bd817fa..2b50904 --- a/vars/Ubuntu-14_Odoo-10.yml +++ b/odoo/vars/Odoo-10.yml @@ -55,7 +55,6 @@ odoo_npm_packages: odoo_pip_dependencies: - pip>=9.0.1 - wrapt - - setuptools>=38.2.3 - odoo-autodiscover==2.0.0 - setuptools-odoo==2.0.2.post1 @@ -68,7 +67,7 @@ odoo_pip_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev @@ -77,7 +76,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - python-virtualenv - build-essential - python-dev - libxml2-dev @@ -85,14 +83,13 @@ odoo_buildout_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev - liblcms2-dev - libwebp-dev - -odoo_wkhtmltox_version: 0.12.1 + - libffi-dev odoo_wkhtmltox_depends: - fontconfig @@ -107,3 +104,14 @@ odoo_wkhtmltox_depends: - libstdc++6 - libc6 - libjpeg-turbo8 + +odoo_wkhtmltox_version: 0.12.1 + +# Try Trusty's package if Xenial one is not found +odoo_wkhtmltox_urls: + # Debian packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-trusty-{{ odoo_debian_arch }}.deb + - http://nightly.odoo.com/extra/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + # generic tar.gz packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-generic-{{ odoo_debian_arch }}.tar.xz diff --git a/vars/Debian-9_Odoo-11.yml b/odoo/vars/Odoo-11.yml old mode 100644 new mode 100755 similarity index 71% rename from vars/Debian-9_Odoo-11.yml rename to odoo/vars/Odoo-11.yml index 0fdaa50..4a77164 --- a/vars/Debian-9_Odoo-11.yml +++ b/odoo/vars/Odoo-11.yml @@ -4,6 +4,9 @@ odoo_debian_packages: - python3-dev - python3-openssl - python3-markupsafe + # Required by pyldap + - libldap2-dev + - libsasl2-dev # Dependencies taken from the deb package - python3-babel - python3-dateutil @@ -23,10 +26,9 @@ odoo_debian_packages: - python3-psutil - python3-psycopg2 - python3-pydot - - python3-pyldap - python3-pyparsing - python3-pypdf2 - - python3-qrcode + # python3-qrcode # Not available in Ubuntu 16.04 - python3-reportlab - python3-requests - python3-serial @@ -34,11 +36,16 @@ odoo_debian_packages: - python3-tz - python3-usb - python3-vatnumber - - python3-vobject - python3-werkzeug - python3-xlsxwriter - python3-yaml +odoo_pypi_packages: + - psycogreen + - qrcode + - pyldap + - vobject + odoo_nodejs_apt_package: "nodejs=6.*" odoo_nodejs_apt_repo: "node_6.x" odoo_npm_packages: @@ -50,9 +57,10 @@ odoo_npm_packages: version: 2.1.15 odoo_pip_dependencies: + - pip>=9.0.1 - wrapt - - setuptools-odoo - odoo-autodiscover + - setuptools-odoo odoo_pip_build_dependencies: - python3-virtualenv @@ -64,15 +72,16 @@ odoo_pip_build_dependencies: - libldap2-dev - libsasl2-dev - libopenjp2-7-dev - - libjpeg62-turbo-dev + - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev - liblcms2-dev - libwebp-dev - libssl-dev + - libffi-dev + - node-less odoo_buildout_build_dependencies: - - virtualenv - build-essential - python3-dev - libxml2-dev @@ -81,14 +90,14 @@ odoo_buildout_build_dependencies: - libldap2-dev - libsasl2-dev - libopenjp2-7-dev - - libjpeg62-turbo-dev + - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev - liblcms2-dev - libwebp-dev -odoo_buildout_venv_cmd: "python3 -m virtualenv --no-setuptools --python=python3 {{ odoo_buildout_venv_path }}" -odoo_pip_venv_cmd: "python3 -m virtualenv --python=python3 {{ odoo_pip_venv_path }}" +odoo_buildout_venv_cmd: "virtualenv --no-setuptools --python=python3 {{ odoo_buildout_venv_path }}" +odoo_pip_venv_cmd: "virtualenv --python=python3 {{ odoo_pip_venv_path }}" odoo_wkhtmltox_version: 0.12.4 @@ -100,4 +109,8 @@ odoo_wkhtmltox_depends: - libx11-6 - libxext6 - libxrender1 - - libjpeg62-turbo + - libjpeg-turbo8 + +odoo_wkhtmltox_urls: + # generic tar.gz packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-generic-{{ odoo_debian_arch }}.tar.xz diff --git a/vars/Ubuntu-14_Odoo-8.yml b/odoo/vars/Odoo-8.yml old mode 100644 new mode 100755 similarity index 65% rename from vars/Ubuntu-14_Odoo-8.yml rename to odoo/vars/Odoo-8.yml index 7061afc..6920256 --- a/vars/Ubuntu-14_Odoo-8.yml +++ b/odoo/vars/Odoo-8.yml @@ -40,12 +40,11 @@ odoo_debian_packages: odoo_pip_dependencies: - pip>=9.0.1 - wrapt - - setuptools>=38.2.3 - odoo-autodiscover==2.0.0 - setuptools-odoo==2.0.2.post1 odoo_pip_build_dependencies: - - python-virtualenv + - virtualenv - build-essential - python-dev - libxml2-dev @@ -53,7 +52,7 @@ odoo_pip_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev @@ -62,7 +61,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - python-virtualenv - build-essential - python-dev - libxml2-dev @@ -70,7 +68,7 @@ odoo_buildout_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev @@ -92,3 +90,12 @@ odoo_wkhtmltox_depends: - libstdc++6 - libc6 - libjpeg-turbo8 + +# Try Trusty's package if Xenial one is not found +odoo_wkhtmltox_urls: + # Debian packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-trusty-{{ odoo_debian_arch }}.deb + - http://nightly.odoo.com/extra/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + # generic tar.gz packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-generic-{{ odoo_debian_arch }}.tar.xz diff --git a/vars/Ubuntu-14_Odoo-9.yml b/odoo/vars/Odoo-9.yml old mode 100644 new mode 100755 similarity index 68% rename from vars/Ubuntu-14_Odoo-9.yml rename to odoo/vars/Odoo-9.yml index fdb18e1..8634aed --- a/vars/Ubuntu-14_Odoo-9.yml +++ b/odoo/vars/Odoo-9.yml @@ -50,7 +50,6 @@ odoo_npm_packages: odoo_pip_dependencies: - pip>=9.0.1 - wrapt - - setuptools>=38.2.3 - odoo-autodiscover==2.0.0 - setuptools-odoo==2.0.2.post1 @@ -63,7 +62,7 @@ odoo_pip_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev @@ -72,7 +71,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - python-virtualenv - build-essential - python-dev - libxml2-dev @@ -80,12 +78,13 @@ odoo_buildout_build_dependencies: - libpq-dev - libldap2-dev - libsasl2-dev - - libopenjpeg-dev + - libopenjp2-7-dev - libjpeg-turbo8-dev - libtiff5-dev - libfreetype6-dev - liblcms2-dev - libwebp-dev + - libffi-dev odoo_wkhtmltox_version: 0.12.1 @@ -102,3 +101,12 @@ odoo_wkhtmltox_depends: - libstdc++6 - libc6 - libjpeg-turbo8 + +# Try Trusty's package if Xenial one is not found +odoo_wkhtmltox_urls: + # Debian packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-trusty-{{ odoo_debian_arch }}.deb + - http://nightly.odoo.com/extra/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-{{ ansible_distribution_release }}-{{ odoo_debian_arch }}.deb + # generic tar.gz packages + - https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/{{ odoo_wkhtmltox_version }}/wkhtmltox-{{ odoo_wkhtmltox_version }}_linux-generic-{{ odoo_debian_arch }}.tar.xz diff --git a/vars/Ubuntu-16_Odoo-10.yml b/odoo/vars/Ubuntu-16_Odoo-10.yml old mode 100644 new mode 100755 similarity index 99% rename from vars/Ubuntu-16_Odoo-10.yml rename to odoo/vars/Ubuntu-16_Odoo-10.yml index 8265785..2b50904 --- a/vars/Ubuntu-16_Odoo-10.yml +++ b/odoo/vars/Ubuntu-16_Odoo-10.yml @@ -76,7 +76,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - virtualenv - build-essential - python-dev - libxml2-dev @@ -90,6 +89,7 @@ odoo_buildout_build_dependencies: - libfreetype6-dev - liblcms2-dev - libwebp-dev + - libffi-dev odoo_wkhtmltox_depends: - fontconfig diff --git a/vars/Ubuntu-16_Odoo-11.yml b/odoo/vars/Ubuntu-16_Odoo-11.yml old mode 100644 new mode 100755 similarity index 98% rename from vars/Ubuntu-16_Odoo-11.yml rename to odoo/vars/Ubuntu-16_Odoo-11.yml index 890ceec..4a77164 --- a/vars/Ubuntu-16_Odoo-11.yml +++ b/odoo/vars/Ubuntu-16_Odoo-11.yml @@ -78,9 +78,10 @@ odoo_pip_build_dependencies: - liblcms2-dev - libwebp-dev - libssl-dev + - libffi-dev + - node-less odoo_buildout_build_dependencies: - - virtualenv - build-essential - python3-dev - libxml2-dev diff --git a/vars/Ubuntu-16_Odoo-8.yml b/odoo/vars/Ubuntu-16_Odoo-8.yml old mode 100644 new mode 100755 similarity index 99% rename from vars/Ubuntu-16_Odoo-8.yml rename to odoo/vars/Ubuntu-16_Odoo-8.yml index f667248..6920256 --- a/vars/Ubuntu-16_Odoo-8.yml +++ b/odoo/vars/Ubuntu-16_Odoo-8.yml @@ -44,7 +44,7 @@ odoo_pip_dependencies: - setuptools-odoo==2.0.2.post1 odoo_pip_build_dependencies: - - python-virtualenv + - virtualenv - build-essential - python-dev - libxml2-dev @@ -61,7 +61,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - virtualenv - build-essential - python-dev - libxml2-dev diff --git a/vars/Ubuntu-16_Odoo-9.yml b/odoo/vars/Ubuntu-16_Odoo-9.yml old mode 100644 new mode 100755 similarity index 99% rename from vars/Ubuntu-16_Odoo-9.yml rename to odoo/vars/Ubuntu-16_Odoo-9.yml index 3aaed1c..8634aed --- a/vars/Ubuntu-16_Odoo-9.yml +++ b/odoo/vars/Ubuntu-16_Odoo-9.yml @@ -71,7 +71,6 @@ odoo_pip_build_dependencies: - libssl-dev odoo_buildout_build_dependencies: - - virtualenv - build-essential - python-dev - libxml2-dev @@ -85,6 +84,7 @@ odoo_buildout_build_dependencies: - libfreetype6-dev - liblcms2-dev - libwebp-dev + - libffi-dev odoo_wkhtmltox_version: 0.12.1 diff --git a/vars/main.yml b/odoo/vars/main.yml old mode 100644 new mode 100755 similarity index 99% rename from vars/main.yml rename to odoo/vars/main.yml index ef46a39..030325a --- a/vars/main.yml +++ b/odoo/vars/main.yml @@ -1,5 +1,7 @@ --- + + odoo_apt_update_cache: yes odoo_apt_cache_valid_time: 86400 @@ -40,3 +42,8 @@ odoo_nodejs_apt_keys: # SSH odoo_ssh_keyscan_cmd: "ssh-keyscan -H -T 10" + + + + + diff --git a/postgresql/README.md b/postgresql/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/postgresql/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/postgresql/defaults/main.yml b/postgresql/defaults/main.yml new file mode 100755 index 0000000..3b7be93 --- /dev/null +++ b/postgresql/defaults/main.yml @@ -0,0 +1,9 @@ +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook +lxd_force: False +odoo_user: ubuntu #Your account to install odoo in odoo host +new_postgresql_db: True #True to create a new database if postgresql_step==True, False to ignore that +odoo_config_db_name: odoodatabase #The name of odoo database +odoo_config_db_user: "{{ odoo_user }}" #The odoo account in PostgreSQL +odoo_config_db_passwd: password #The passowrd of odoo account in PostgreSQL +odoo_config_db_user_righs: "NOCREATEDB,NOSUPERUSER" #The right what odoo account in Postgresql have diff --git a/postgresql/tasks/main.yml b/postgresql/tasks/main.yml new file mode 100755 index 0000000..b05ab16 --- /dev/null +++ b/postgresql/tasks/main.yml @@ -0,0 +1,94 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# This block when postgresql_step is True +# This block to install PostgreSQL and config it to work with Odoo +# kw-install-pkg +- name: Ensure libpq-dev is installed. + delegate_to: "{{ lxd_container_name }}" + apt: pkg=libpq-dev state=present + +# kw-install-pkg +- name: Ensure python-psycopg2 is installed. + delegate_to: "{{ lxd_container_name }}" + apt: pkg=python-psycopg2 state=present + +# kw-install-pkg kw-postgresql +- name: Ensure PostgreSQL is installed. + delegate_to: "{{ lxd_container_name }}" + apt: pkg=postgresql state=present + +# kw-postgresql kw-configure kw-user kw-create +- name: Create "{{ odoo_config_db_user }}" user into PostgreSQL. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + postgresql_user: + name: "{{ odoo_config_db_user }}" + password: "{{ odoo_config_db_passwd }}" + role_attr_flags: "{{ odoo_config_db_user_righs }}" + when: new_postgresql_db + +# kw-postgresql kw-configure kw-create +- name: Ensure "{{ odoo_config_db_name }}" database is created. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + postgresql_db: name="{{ odoo_config_db_name }}" + encoding=UTF-8 + lc_collate=en_US.UTF-8 + lc_ctype=en_US.UTF-8 + state=present + owner="{{ odoo_config_db_user }}" + login_password="{{ odoo_config_db_passwd }}" + template=template0 + when: new_postgresql_db + +# kw-postgresql kw-configure kw-user +- name: Ensure "{{ odoo_config_db_user }}" user has access to the "{{ odoo_config_db_name }}" database. + become_user: postgres + delegate_to: "{{ lxd_container_name }}" + postgresql_privs: + database: "{{ odoo_config_db_name }}" + state: present + privs: ALL + type: database + roles: "{{ odoo_config_db_user }}" + grant_option: yes + when: new_postgresql_db + + diff --git a/rsnapshot/README.md b/rsnapshot/README.md new file mode 100755 index 0000000..76ec234 --- /dev/null +++ b/rsnapshot/README.md @@ -0,0 +1,303 @@ +ansible-lxd-odoo +================ + +Ansible is an IT automation tool. In this project, "Ansible LXD Odoo", we use it to automate the installation and configuration of Odoo in an LXD container. + +Ansible layout +-------------- + +### Working folder + +In any working folder we have: + +`ansible.cfg`: Configuration file. + +`hosts`: File that has the names of nodes that we can access by ssh or lxd protocol or any protocol that Ansible supports + +`playbook.yml`: In this file we tell Ansible: please install roles on some nodes. We can manipulate Ansible roles by putting some variables here. We can store many Playbook YML files in ansible working folder, that with different name indicates why we use it (eg. buildout.yml, create_container.yml, config_db.yml) and run these as single files in a single comand as to what we need. + +`roles`: Inside this folder we must have at least one role folder, like 'ansible-odoo'. + +### Role folders + +In a role folder we have the following: + +`tasks`: Required folder that contains the main actions to be done in this role. `tasks/main.yml` is the tasks entry point. + +`vars`: Folder that contains the variables for this role. Variables allow tasks to choose between different behaviours, based on the situation. + +`defaults`: Contains the defaults for variables in this role. `defaults/main.yml` is the entry point. + +`files`: This directory holds files that can be copied as-is on the remote nodes. + +`templates`: This directory holds files (templates) that still need some variables to be filled in before copying to the remote node. + +Installation +------------ + +### Remote server + +NB. for testing purposes, the remote server can be `localhost`! + +The remote server should be Ubuntu, because it's the only Linux that currently supports LXC. The configuration of the server is done by Ansible. + +Should you wish to install LXC manually: + +``` +sudo apt-get install lxc +``` + +### Control server + +NB. for testing purposes, the control server can be `localhost`! When working as a single person, you could even stick with controlling your remote server(s) from localhost indefinitely. + +#### Installing Ansible + +The control server runs Ansible. We should install it by: + +``` +sudo apt-get update +sudo apt-get install software-properties-common +sudo apt-add-repository ppa:ansible/ansible +sudo apt-get update +sudo apt-get install ansible +``` + +Then we copy /etc/ansible folder to home directory, and edit ansible.cfg file clear all lines in it and put this line: + +``` +[defaults] +inventory = hosts +enable_task_debugger = True +``` + +Then we edit `hosts` file. +Clear all lines in it and put `localhost` or the name of your remote server. When using Ansible in `paramiko` or `ssh` mode, it is allowed to use names that refer to shortcut configurations from your `$HOME/.ssh/config` file. + +#### Installing the Ansible LXD Odoo role + +We `git clone` our repository in the roles folder: + +``` +cd roles +git clone https://github.com/sunflowerit/ansible-odoo +git checkout 431-latest-work +``` + +Usage +----- + +### Example: default setup + +Touch `default.yml` in ansible works directory and put these lines into it: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo +``` + +then run this command: `ansible-playbook -K default.yml` + +By this command ansible runs with default variables so the roles will do these steps: + +1. Create LXD container: `lxdcontainer` and put `lxdcontainer ansible_connection=lxd` line in ansible inventory hosts file `hosts` to make `lxdcontainer` available in ansible environment +2. Copy id_rsa from the .ssh folder in home server user folder: /home/odoo/.ssh/id_rsa to the .ssh folder in home container user folder: /home/ubuntu/.ssh/ +3. Change container network type from DHCP mode to static IP mode with same 'lxdcontainer' setting that given it by DHCP. +4. Install postgresql into lxdcontainer, and create user: 'ubuntu' into postgresql with password: 'password' and with (NOCREATE, NOSUBERUSER) rights. +5. Create database: 'odoodatabase', and grant 'ubuntu' to be owner of 'odoodatabase'. +6. Install some packages: `sudo`, `git`, `mercurial`, `python-pip`, `python-psycopg2`, `nl_NL.UTF-8`. in LXD container. +7. Download branch 9.0 from repository `https://github.com/sunflowerit/custom-installations/tree/9.0-custom-standard` +8. Install some packages: `build-essential`, `python-dev`, `libxml2-dev`, `libxslt1-dev`, `libpq-dev`, `libldap2-dev`, `libsasl2-dev`, `libopenjp2-7-dev`, `libjpeg-turbo8-dev`, `libtiff5-dev`, `libfreetype6-dev`, `liblcms2-dev`, `libwebp-de`. +9. Create `/home/ubuntu/odoo/local.cfg` in container OS. the default content of local.cfg is: + +``` +[buildout] +extends = odoo8-standard.cfg + +[odoo] +options.admin_passwd = admin +options.db_host = localhost +options.db_name = odoodatabase +options.db_port = 5432 +options.db_user = ubuntu +options.db_password = password +options.xmlrpc_port = 8069 +options.longpolling_port = 8072 +``` + +10. Run this command: `/usr/bin/python /home/ubuntu/odoo/bootstrap.py -c /home/ubuntu/odoo/local.cfg --buildout-version 2.11.4` +11. Install setuptools version: `38.1.0` +12. Download https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt +13. install pip pkg that in requirements.txt. +14. run this command: /home/ubuntu/odoo/bin/buildout -c /home/ubuntu/odoo/local.cfg +15. then install `less`, `less-plugin-clean-css`, `phantomjs-prebuilt` if we build odoo 9.0 or 10.0 +16. Download `wkhtmltox` +17. Install wkhtmltox dependencies and wkhtmltox 'generic package' +18. Download the ReportLab barcode fonts then unzip it +19. Generate odoo service files +20. create /etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl, the default content in lxdcontainer.sunflowerodoo.nl is: + +``` + server { + listen 80; + server_name lxdcontainer.sunflowerodoo.nl; + + client_max_body_size 200M; + + proxy_connect_timeout 6000s; + proxy_send_timeout 6000s; + proxy_read_timeout 6000s; + send_timeout 6000s; + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; + + location / { + proxy_pass http://{{ odoo_ip }}:8069; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + + } + + location /longpolling { + proxy_pass http://{{ odoo_ip }}:8072; + } + +} +``` + +21. Make a link in `/etc/nginx/sites-enabled/lxdcontainer.sunflowerodoo.nl` to `/etc/nginx/sites-available/lxdcontainer.sunflowerodoo.nl` +22. Try to reload nginx by this command: `nginx -t && nginx -s reload` + +### Example 2: modified setup + +Now we can change ansible-playbook behavior by put some variable value in playbook.yml. + +For example, to make a new container and give it simple odoo10 and install odoo 10.0 inside this container from 10.0-custom-standard branch and configure nginx to make this container available in simpleodoo10.sunflowerodoo.nl we touch odoo_10_default.yml in ansible working directory and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + odoo_config_db_name: odoodatabase + lxd_container_name: simpleodoo10 + branch: 10.0-custom-standard +``` + +Then we run this command: + +`ansible-playbook -K odoo_10_default.yml` + +### Example 3: modified setup + +To create a new container 'cleanlxdcontainer', install postgres with and create 'simpleuser' user with 'TlTtLLtt' password in database and grant it to have CREATEDB,SUPERUSER without creat database and without download odoo and without install odoo and without config nginx we touch simple_lxd.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + new_postgresql_db: false + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + odoo_config_db_user_righs: "CREATEDB,SUPERUSER" + buildout_step: false + nginx_step: false +``` + +Then we run this command: + +`ansible-playbook -K simple_lxd.yml` + +### Example 4: modified setup + +For example we can move some database to 'cleanlxdcontainer', and then we need to install odoo 10.0 from branch 9.0-custom-standard with custom buildout file we had before like custom.cfg. We plan to use buildout version 2.8.0, and build it to use the database 'somedatabase' we moved it to container manually before. We plan to ignore installing `less` and the `reportlab` packages, and we need to make odoo available on xmlrpc port '8090' and on longpolling port '8095' and configure nginx to make this container availabe in test.sunflowerodoo.nl. + +Then, wwe must put custom.cfg in roles/files/odoo_config_files/ and edit simple_lxd.yml in ansible works directory to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + lxd_container_name: cleanlxdcontainer + lxd_step: false + odoo_version: 10.0 + buildout_config_file: custome.cfg + github_account: [ your accont on github allow you to acces to sunflower instance ] + github_account_name: [ your name ] + odoo_buildout_version: 2.8.0 + odoo_config_db_user: simpleuser + odoo_config_db_passwd: TlTtLLtt + app_after_buildout: false + buildout_step: true + nginx_step: true + nginx_subdomain: test + odoo_config_xmlrpc_port: 8090 + odoo_config_longpolling_port: 8095 +then we run this command +ansible-playbook -K -e new_lxd_container=false simple_lxd.yml +``` + +### Example 5: modified setup + +if we plan to create 'customuser' container and creat 'customer' system user with 'wQrEyTuY' password and with vertual enviroment in that container and install postgresql with default 'odoodatabase' database and default database user and password and downlowad odoo 8.0 from bransh 9.0-custom-standard but without run bootstrap and without run buildout and make it avialable at customuser.sunflowerserver.nl we touch customer.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 8.0 + lxd_container_name: customuser + odoo_user: customer + odoo_user_passwd: wQrEyTuY + env_type: true + run_bootstrap: false + run_buildout: false + nginx_domain: sunflowerserver.nl +then we run this command +ansible-playbook -K customer.yml +``` + +### Example 6: modified setup + +Now if we plan to install default odoo 10.0 directly on server and create 'odoouser' system user with 'SaFdHgKj' password for that and install odoo 10.0 in vertual inviroment and config it to be available on xmlrpc port '8016' and on longpolling port '8019' and config nginx to make this container available at odoo10local.sunflowerodoo.nl we touch odoo10local.yml and edit it to be: + +``` +- name: Odoo + hosts: localhost + connection: local + become: yes + roles: + - role: ansible-odoo + odoo_version: 10.0 + lxd_type: false + odoo_user: odoouser + odoo_user_passwd: SaFdHgKj + env_type: true + nginx_subdomain: odoo10local + odoo_config_xmlrpc_port: 8016 + odoo_config_longpolling_port: 8019 +``` + diff --git a/rsnapshot/defaults/main.yml b/rsnapshot/defaults/main.yml new file mode 100755 index 0000000..bd07e22 --- /dev/null +++ b/rsnapshot/defaults/main.yml @@ -0,0 +1,9 @@ +lxd_host_user: odoo +lxd_host_ip: 188.166.24.182 +lxd_container_name: test #The name you giv to a new LXD container +new_lxd_container: True #This condition to be carefull about exist containers when you run ansible-playbook +lxd_force: False +rsnapshot_server_name: rsnapshot +rsnapshot_server_ip: 10.10.10.70 +rsnapshot_hosts_dir: /etc/rsnapshot/hosts +rsnapshot_backup_dir: /mnt/volume-fra1-01/backup/lxd/rsnapshot diff --git a/rsnapshot/tasks/main.yml b/rsnapshot/tasks/main.yml new file mode 100755 index 0000000..42c2168 --- /dev/null +++ b/rsnapshot/tasks/main.yml @@ -0,0 +1,174 @@ +--- +#KEY WORDS: +#kw-check kw-message kw-ansible kw-install kw-configure kw-set_var +#kw-networking kw-restart kw-user kw-system kw-ssh kw-postgresql +#kw-backup kw-barman kw-rsnapshot kw-nginx kw-restart kw-install-pkg + +- debug: + msg: "'localhost' name isn't accebted as a container name in this ansible playbook." + when: lxd_container_name == "localhost" + +- meta: end_play + when: lxd_container_name == "localhost" + +# kw-ansible kw-check kw-set_var +- name: check "{{ lxd_container_name }}" container if exist. + shell: "lxc list |grep ' {{ lxd_container_name }} ' |cut -d'|' -f6 | awk '{print $1}'" + register: lxd_state + +# kw-ansible kw-message +- debug: + msg: The {{ lxd_container_name }} container is exist! + when: lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible +- meta: end_play + when: new_lxd_container == True and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-ansible kw-message +- name: " (^_^) Be careful (^_^) ." + debug: + msg: + - Warning Warning Warning Warning + - You chose 'new_lxd_container == False', That mean ansible will overwrite the exist container. + - If you are sure press 'c' then 'Enter' to continue. + - If you make it by mistake press 'q' then 'Enter' then correct new_lxd_container variable to be 'True' and chose another lxd_container_name, then rerun ansible-playbook. + failed_when: True + ignore_errors: True + when: new_lxd_container == False and lxd_state.stdout == "PERSISTENT" and lxd_force == False + +# kw-networking kw-set_var +- name: Get "{{ lxd_container_name }}" container IP. + delegate_to: "{{ lxd_container_name }}" + shell: "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d ':' -f2 | awk '{print $1}'" + register: container_ip + +- name: Remove root@{{ lxd_container_name }} ssh configuration from root@{{ rsnapshot_server_name }}:/root/.ssh/config if exest. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + replace: + path: /root/.ssh/config + regexp: "(?=Host {{ lxd_container_name }}\n)(((.+\n)+)\n*?)(?=\n)" + replace: "" + +- name: Create root@{{ lxd_container_name }} ssh configuration in root@{{ rsnapshot_server_name }}:/root/.ssh/config. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + blockinfile: + dest: /root/.ssh/config + state: present + marker: "" + block: | + Host {{ lxd_container_name }} + ForwardAgent yes + Hostname {{ container_ip.stdout }} + Port 22 + User root + StrictHostKeyChecking no + ProxyCommand ssh {{ lxd_host_user }}@{{ lxd_host_ip }} nc %h 22 + +# kw-rsnapshot kw-set_var kw-ssh +- name: Get the root@{{ rsnapshot_server_name }} ssh key. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + slurp: + src: '/root/.ssh/id_rsa.pub' + register: root_ssh_key + +# kw-rsnapshot kw-set_var kw-ssh +- name: Extract root@{{ rsnapshot_server_name }} ssh key. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + set_fact: + rsnapshot_register_ssh: + comment: 'root@{{ container_ip.stdout }}' + key: '{{ root_ssh_key.content | b64decode | trim }}' + +# kw-rsnapshot kw-create kw-ssh +- name: Deploy ssh key on root@{{ lxd_container_name }}. + delegate_to: "{{ lxd_container_name }}" + authorized_key: + user: 'root' + key: '{{ rsnapshot_register_ssh.key + " " + rsnapshot_register_ssh.comment }}' + key_options: 'no-pty,no-agent-forwarding,no-X11-forwarding,no-port-forwarding,command="ionice -c 3 nice /usr/local/lib/rrsync -ro /"' + state: 'present' + +# kw-rsnapshot kw-create kw-ssh +- name: Touch Known_hosts for root@{{ rsnapshot_server_name }}. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + file: + path: /root/.ssh/known_hosts + state: touch + mode: 0600 + owner: root + group: root + +# kw-rsnapshot kw-check +- name: Check if ~/.profile file exists on root@{{ lxd_container_name }}. + delegate_to: "{{ lxd_container_name }}" + stat: + path: ~/.profile + register: rsnapshot_register_root_profile + +# kw-rsnapshot kw-create +- name: Fix shell 'stdin is not a tty' issue for root@{{ lxd_container_name }}. + delegate_to: "{{ lxd_container_name }}" + lineinfile: + dest: '~/.profile' + regexp: 'mesg n$' + line: 'tty -s && mesg n' + state: 'present' + create: 'no' + when: rsnapshot_register_root_profile.stat.exists == True + +- name: Prepare rrsync script for secure rsync backups + delegate_to: "{{ lxd_container_name }}" + shell: gzip -d -c /usr/share/doc/rsync/scripts/rrsync.gz > /usr/local/lib/rrsync ; + chmod 0755 /usr/local/lib/rrsync +# args: +# creates: /usr/local/lib/rrsync + +- name: Ensure {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }} folder is exists. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + file: + path: "{{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}" + state: directory + mode: 0755 + owner: root + group: root + +- name: Configure {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/exclude.txt on "{{ rsnapshot_server_name }}" server. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + template: + src: exclude.txt.j2 + dest: "{{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/exclude.txt" + force: yes + owner: root + group: root + mode: 0644 + +- name: Configure {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/include.txt on "{{ rsnapshot_server_name }}" server. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + template: + src: include.txt.j2 + dest: "{{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/include.txt" + force: yes + owner: root + group: root + mode: 0644 + +- name: Configure {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/rsnapshot.conf on "{{ rsnapshot_server_name }}" server. + become_user: root + delegate_to: "{{ rsnapshot_server_name }}" + template: + src: rsnapshot.conf.j2 + dest: "{{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/rsnapshot.conf" + force: yes + owner: root + group: root + mode: 0644 + diff --git a/rsnapshot/templates/exclude.txt.j2 b/rsnapshot/templates/exclude.txt.j2 new file mode 100755 index 0000000..2045ed1 --- /dev/null +++ b/rsnapshot/templates/exclude.txt.j2 @@ -0,0 +1,44 @@ +# Ansible managed + +- /bin +- /boot +- /cdrom +- /dev +- /lib +- /lib32 +- /lib64 +- /media +- /mnt +- /proc +- /run +- /sbin +- /selinux +- /sys +- /tmp ++ /usr/local +- /usr/* +- /initrd* +- /swapfile* +- /vmlinuz* +- /vz + +- /var/agentx +- /var/cache +- /var/lib/apt +- /var/lib/amavis/tmp +- /var/lib/libvirt/images +- /var/lib/lxc +- /var/lib/lxcsnaps +- /var/lib/mysql +- /var/lib/postgresql +- /var/lib/python-support ++ /var/lib/vz/dump +- /var/lib/vz/* +- /var/lock +- /var/run +- /var/spool/postfix +- /var/tmp +- /home/*/buildout/parts/* +- /home/*/buildout/eggs/* +- /var/swap.img + diff --git a/rsnapshot/templates/include.txt.j2 b/rsnapshot/templates/include.txt.j2 new file mode 100755 index 0000000..73bef61 --- /dev/null +++ b/rsnapshot/templates/include.txt.j2 @@ -0,0 +1,3 @@ +# Ansible managed + ++ /* diff --git a/rsnapshot/templates/rsnapshot.conf.j2 b/rsnapshot/templates/rsnapshot.conf.j2 new file mode 100755 index 0000000..4c9949d --- /dev/null +++ b/rsnapshot/templates/rsnapshot.conf.j2 @@ -0,0 +1,264 @@ +# Ansible managed + +################################################# +# rsnapshot.conf - rsnapshot configuration file # +################################################# +# # +# PLEASE BE AWARE OF THE FOLLOWING RULES: # +# # +# This file requires tabs between elements # +# # +# Directories require a trailing slash: # +# right: /home/ # +# wrong: /home # +# # +################################################# + +####################### +# CONFIG FILE VERSION # +####################### + +config_version 1.2 + +########################### +# SNAPSHOT ROOT DIRECTORY # +########################### + +# All snapshots will be stored under this root directory. +# +snapshot_root {{ rsnapshot_backup_dir }}/{{ lxd_container_name }} + +# If no_create_root is enabled, rsnapshot will not automatically create the +# snapshot_root directory. This is particularly useful if you are backing +# up to removable media, such as a FireWire or USB drive. +# +#no_create_root 1 + +################################# +# EXTERNAL PROGRAM DEPENDENCIES # +################################# + +# LINUX USERS: Be sure to uncomment "cmd_cp". This gives you extra features. +# EVERYONE ELSE: Leave "cmd_cp" commented out for compatibility. +# +# See the README file or the man page for more details. +# +cmd_cp /bin/cp + +# uncomment this to use the rm program instead of the built-in perl routine. +# +#cmd_rm /bin/rm + +# rsync must be enabled for anything to work. This is the only command that +# must be enabled. +# +cmd_rsync /usr/local/lib/rsync-no-vanished + +# Uncomment this to enable remote ssh backups over rsync. +# +cmd_ssh /usr/bin/ssh + +# Comment this out to disable syslog support. +# +cmd_logger /usr/bin/logger + +# Uncomment this to specify the path to "du" for disk usage checks. +# If you have an older version of "du", you may also want to check the +# "du_args" parameter below. +# +#cmd_du /usr/bin/du + +# Uncomment this to specify the path to rsnapshot-diff. +# +#cmd_rsnapshot_diff /usr/bin/rsnapshot-diff + +# Specify the path to a script (and any optional arguments) to run right +# before rsnapshot syncs files +# +#cmd_preexec /path/to/preexec/script + +# Specify the path to a script (and any optional arguments) to run right +# after rsnapshot syncs files +# +#cmd_postexec /path/to/postexec/script + +# Paths to lvcreate, lvremove, mount and umount commands, for use with +# Linux LVMs. +# +#linux_lvm_cmd_lvcreate /path/to/lvcreate +#linux_lvm_cmd_lvremove /path/to/lvremove +#linux_lvm_cmd_mount /bin/mount +#linux_lvm_cmd_umount /bin/umount + +######################################### +# BACKUP INTERVALS # +# Must be unique and in ascending order # +# i.e. hourly, daily, weekly, etc. # +######################################### + +#retain hourly 6 +retain daily 30 +#retain weekly 4 +retain monthly 6 + +############################################ +# GLOBAL OPTIONS # +# All are optional, with sensible defaults # +############################################ + +# Verbose level, 1 through 5. +# 1 Quiet Print fatal errors only +# 2 Default Print errors and warnings only +# 3 Verbose Show equivalent shell commands being executed +# 4 Extra Verbose Show extra verbose information +# 5 Debug mode Everything +# +#verbose 2 + +# Same as "verbose" above, but controls the amount of data sent to the +# logfile, if one is being used. The default is 3. +# +#loglevel 3 + +# If you enable this, data will be written to the file you specify. The +# amount of data written is controlled by the "loglevel" parameter. +# +logfile /var/log/rsnapshot/{{ lxd_container_name }}.log + +# If enabled, rsnapshot will write a lockfile to prevent two instances +# from running simultaneously (and messing up the snapshot_root). +# If you enable this, make sure the lockfile directory is not world +# writable. Otherwise anyone can prevent the program from running. +# +lockfile /var/run/rsnapshot-{{ lxd_container_name }}.pid + +# By default, rsnapshot check lockfile, check if PID is running +# and if not, consider lockfile as stale, then start +# Enabling this stop rsnapshot if PID in lockfile is not running +# +#stop_on_stale_lockfile 0 + +# Default rsync args. All rsync commands have at least these options set. +# +#rsync_short_args -a +#rsync_long_args --delete --numeric-ids --relative --delete-excluded + +# ssh has no args passed by default, but you can specify some here. +# +# In Debian Jessie, rsnapshot has a bug related to 'ssh_args' option, +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717451 +# Until a bugfix is released, 'ssh_args' option is disabled by default to allow +# for backups to be processed +#ssh_args -p 22 + +# Default arguments for the "du" program (for disk space reporting). +# The GNU version of "du" is preferred. See the man page for more details. +# If your version of "du" doesn't support the -h flag, try -k flag instead. +# +#du_args -csh + +# If this is enabled, rsync won't span filesystem partitions within a +# backup point. This essentially passes the -x option to rsync. +# The default is 0 (off). +# +one_fs 0 + +# The include and exclude parameters, if enabled, simply get passed directly +# to rsync. If you have multiple include/exclude patterns, put each one on a +# separate line. Please look up the --include and --exclude options in the +# rsync man page for more details on how to specify file name patterns. +# +#include ??? +#include ??? +#exclude ??? +#exclude ??? # + +# The include_file and exclude_file parameters, if enabled, simply get +# passed directly to rsync. Please look up the --include-from and +# --exclude-from options in the rsync man page for more details. +# +exclude_file {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/exclude.txt +include_file {{ rsnapshot_hosts_dir }}/{{ lxd_container_name }}/include.txt + +# If your version of rsync supports --link-dest, consider enable this. +# This is the best way to support special files (FIFOs, etc) cross-platform. +# The default is 0 (off). +# +link_dest 1 + +# When sync_first is enabled, it changes the default behaviour of rsnapshot. +# Normally, when rsnapshot is called with its lowest interval +# (i.e.: "rsnapshot hourly"), it will sync files AND rotate the lowest +# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync, +# and all interval calls simply rotate files. See the man page for more +# details. The default is 0 (off). +# +sync_first 1 + +# If enabled, rsnapshot will move the oldest directory for each interval +# to [interval_name].delete, then it will remove the lockfile and delete +# that directory just before it exits. The default is 0 (off). +# +#use_lazy_deletes 0 + +# Number of rsync re-tries. If you experience any network problems or +# network card issues that tend to cause ssh to crap-out with +# "Corrupted MAC on input" errors, for example, set this to a non-zero +# value to have the rsync operation re-tried +# +#rsync_numtries 0 + +# LVM parameters. Used to backup with creating lvm snapshot before backup +# and removing it after. This should ensure consistency of data in some special +# cases +# +# LVM snapshot(s) size (lvcreate --size option). +# +#linux_lvm_snapshotsize 100M + +# Name to be used when creating the LVM logical volume snapshot(s). +# +#linux_lvm_snapshotname rsnapshot + +# Path to the LVM Volume Groups. +# +#linux_lvm_vgpath /dev + +# Mount point to use to temporarily mount the snapshot(s). +# +#linux_lvm_mountpath /path/to/mount/lvm/snapshot/during/backup + +############################### +### BACKUP POINTS / SCRIPTS ### +############################### + +backup root@{{ lxd_container_name }}:/ ./ + + +# LOCALHOST +#backup /home/ localhost/ +#backup /etc/ localhost/ +#backup /usr/local/ localhost/ +#backup /var/log/rsnapshot localhost/ +#backup /etc/passwd localhost/ +#backup /home/foo/My Documents/ localhost/ +#backup /foo/bar/ localhost/ one_fs=1, rsync_short_args=-urltvpog +#backup_script /usr/local/bin/backup_pgsql.sh POSTGRESQL/ +# You must set linux_lvm_* parameters below before using lvm snapshots +#backup lvm://vg0/xen-home/ lvm-vg0/xen-home/ + +# EXAMPLE.COM +#backup_script /bin/date "+ backup of example.com started at %c" unused1 +#backup root@example.com:/home/ example.com/ +rsync_long_args=--bwlimit=16,exclude=core +#backup root@example.com:/etc/ example.com/ exclude=mtab,exclude=core +#backup_script ssh root@example.com "mysqldump -A > /var/db/dump/mysql.sql" unused2 +#backup root@example.com:/var/db/dump/ example.com/ +#backup_script /bin/date "+ backup of example.com ended at %c" unused9 + +# CVS.SOURCEFORGE.NET +#backup_script /usr/local/bin/backup_rsnapshot_cvsroot.sh rsnapshot.cvs.sourceforge.net/ + +# RSYNC.SAMBA.ORG +#backup rsync://rsync.samba.org/rsyncftp/ rsync.samba.org/rsyncftp/ + +# vim:ft=conf diff --git a/tasks/config.yml b/tasks/config.yml deleted file mode 100644 index 95b2e86..0000000 --- a/tasks/config.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Generate Odoo configuration file - template: src=odoo-{{ odoo_version }}.conf dest={{ odoo_config_file }} - owner={{ odoo_user }} group={{ odoo_user }} mode=0600 - force={{ odoo_force_config and 'yes' or 'no' }} - backup=yes - notify: Restart Odoo diff --git a/tasks/install.yml b/tasks/install.yml deleted file mode 100644 index fcca158..0000000 --- a/tasks/install.yml +++ /dev/null @@ -1,96 +0,0 @@ ---- - -- name: Install required tools - apt: pkg={{ item }} - state=installed - update_cache={{ odoo_apt_update_cache }} - cache_valid_time={{ odoo_apt_cache_valid_time }} - with_items: "{{ odoo_required_tools }}" - tags: - - odoo_required_tools - -- name: Add Odoo system user - user: - name: "{{ odoo_user }}" - shell: "{{ odoo_user_shell }}" - password: "{{ odoo_user_passwd }}" - update_password: "{{ odoo_user_update_password }}" - system: "{{ odoo_user_system }}" - tags: - - odoo_user - -- name: Configure SSH for the Odoo user - import_tasks: install_ssh.yml - tags: - - odoo_install_ssh - -- name: Create log directory - file: path={{ odoo_logdir }} state=directory - owner={{ odoo_user }} group={{ odoo_user }} force=no - tags: - - odoo_log - -- name: Project repository already cloned? - stat: path={{ odoo_repo_dest }} - register: project_path - tags: - - odoo_project - -- name: Clone project repository (Mercurial) - become: yes - become_user: "{{ odoo_user }}" - hg: repo={{ odoo_repo_url }} - dest={{ odoo_repo_dest }} - revision={{ odoo_repo_rev | string }} - when: odoo_repo_type == 'hg' and odoo_repo_url - and (odoo_repo_update or (project_path.stat.exists == False)) - notify: Restart Odoo - tags: - - odoo_project - -- name: Clone project repository (Git) - become: yes - become_user: "{{ odoo_user }}" - git: repo={{ odoo_repo_url }} - dest={{ odoo_repo_dest }} - version={{ odoo_repo_rev | string }} - update={{ project_path.stat.exists == False and 'yes' - or (odoo_repo_update and 'yes' or 'no') }} - depth={{ odoo_repo_depth }} - when: odoo_install_type != 'pip' and odoo_repo_type == 'git' and odoo_repo_url - notify: Restart Odoo - tags: - - odoo_project - -- name: Create odoo data dir directory - file: path={{ odoo_config_data_dir }} state=directory - owner={{ odoo_user }} group={{ odoo_user }} force=yes - when: odoo_install_type != 'buildout' - tags: - - odoo_install_type_pip - - odoo_install_type_standard - -- name: Standard installation - import_tasks: install_standard.yml - when: odoo_install_type == 'standard' - tags: - - odoo_install_type_standard - -- name: Buildout installation - import_tasks: install_buildout.yml - when: odoo_install_type == 'buildout' - tags: - - odoo_install_type_buildout - -- name: Pip installation - import_tasks: install_pip.yml - when: odoo_install_type == 'pip' - tags: - - odoo_install_type_pip - -- name: Install NPM packages - import_tasks: install_npm.yml - when: (odoo_version | int) >= 9 - tags: - - odoo - - odoo_packages diff --git a/tasks/install_buildout.yml b/tasks/install_buildout.yml deleted file mode 100644 index 583651d..0000000 --- a/tasks/install_buildout.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- - -- name: Install build dependencies - apt: pkg={{ item }} - state=installed - update_cache={{ odoo_apt_update_cache }} - cache_valid_time={{ odoo_apt_cache_valid_time }} - with_items: "{{ odoo_buildout_build_dependencies }}" - -- name: Install extra dependencies - apt: pkg={{ item }} - state=installed - update_cache={{ odoo_apt_update_cache }} - cache_valid_time={{ odoo_apt_cache_valid_time }} - with_items: "{{ odoo_buildout_extra_dependencies }}" - -- name: Prepare the Python virtual environment - become: yes - become_user: "{{ odoo_user }}" - shell: "{{ odoo_buildout_venv_cmd }}" - args: - creates: "{{ odoo_buildout_venv_path }}" - -- name: Copy the bootstrap.py script - copy: src=bootstrap.py dest={{ odoo_buildout_bootstrap_path }} - owner={{ odoo_user }} group={{ odoo_user }} force=no - -- name: Install buildout (run the bootstrap.py script) - become: yes - become_user: "{{ odoo_user }}" - command: "{{ odoo_buildout_bootstrap_cmd }}" - args: - creates: "{{ odoo_buildout_bin_path }}" - -- name: Run buildout - become: yes - become_user: "{{ odoo_user }}" - command: "{{ odoo_buildout_bin_path }} -c {{ odoo_buildout_config_path }}" - changed_when: False diff --git a/tasks/install_npm.yml b/tasks/install_npm.yml deleted file mode 100644 index 40becdf..0000000 --- a/tasks/install_npm.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -- name: Configure NodeJS APT repository signing key - apt_key: - url: "{{ item.url }}" - state: "{{ item.state }}" - with_items: "{{ odoo_nodejs_apt_keys | default([]) }}" - -- name: Configure NodeJS APT repository - apt_repository: - repo: "{{ item.repo }}" - state: "{{ item.state }}" - with_items: "{{ odoo_nodejs_apt_repositories | default([]) }}" - -- name: Install NodeJS - apt: pkg="{{ odoo_nodejs_apt_package }}" - state=installed - update_cache=yes - -- name: Install Odoo dependencies (npm) - npm: name={{ item.name }} - version={{ item.version }} - global=yes - with_items: "{{ odoo_npm_packages | default([]) }}" diff --git a/tasks/install_pip.yml b/tasks/install_pip.yml deleted file mode 100644 index 574dfa0..0000000 --- a/tasks/install_pip.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- - -- name: Generate sample requirements.txt file - template: src=odoo-{{ odoo_version }}-pip-requirements.txt dest="/home/{{ odoo_user }}/requirements.txt" - owner={{ odoo_user }} group={{ odoo_user }} mode=0600 - -- name: Install build dependencies - apt: pkg={{ item }} - state=installed - update_cache={{ odoo_apt_update_cache }} - cache_valid_time={{ odoo_apt_cache_valid_time }} - with_items: "{{ odoo_pip_build_dependencies }}" - -- name: Prepare the Python virtual environment - become: yes - become_user: "{{ odoo_user }}" - shell: "{{ odoo_pip_venv_cmd }}" - args: - creates: "{{ odoo_pip_venv_path }}" - -- name: Download the pip requirements file - become: yes - become_user: "{{ odoo_user }}" - get_url: url="{{ odoo_pip_requirements_url }}" - force=yes - dest="/home/{{ odoo_user }}/requirements.txt" - -- name: Install Odoo dependencies (PyPi) - become: yes - become_user: "{{ odoo_user }}" - pip: - name: "{{ item }}" - virtualenv: "{{ odoo_pip_venv_path }}" - with_items: "{{ odoo_pip_dependencies }}" - -- name: Install Odoo from pip external requirements file - become: yes - become_user: "{{ odoo_user }}" - pip: - requirements: /home/{{ odoo_user }}/requirements.txt - extra_args: --upgrade - virtualenv: "{{ odoo_pip_venv_path }}" - notify: Restart Odoo - -- import_tasks: config.yml - tags: - - odoo_config diff --git a/tasks/install_ssh.yml b/tasks/install_ssh.yml deleted file mode 100644 index 905e228..0000000 --- a/tasks/install_ssh.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- - -- block: - - - name: SSH - Install private and public keys for the Odoo user - copy: - src: "{{ item.value }}" - dest: "{{ odoo_user_ssh_dir }}/id_rsa{{ '.pub' if item.key == 'pub' else '' }}" - mode: "{{ '0600' if item.key == 'priv' else '0644' }}" - with_dict: "{{ odoo_user_ssh_key }}" - - - name: SSH - Remove private and public keys if none is defined - file: - path: "{{ item }}" - state: absent - with_list: - - "{{ odoo_user_ssh_dir }}/id_rsa" - - "{{ odoo_user_ssh_dir }}/id_rsa.pub" - when: not odoo_user_ssh_key - - - name: SSH - Make sure the SSH directory exists - file: - path: "{{ odoo_user_ssh_dir }}" - state: directory - mode: 0700 - changed_when: no - - - name: SSH - Make sure the known_hosts file exists - file: - path: "{{ odoo_user_ssh_known_hosts_file }}" - state: touch - changed_when: no - - - name: SSH - Check host name availability in the known hosts file - shell: "ssh-keygen -f {{ odoo_user_ssh_known_hosts_file }} -F {{ item }}" - with_items: "{{ odoo_user_ssh_known_hosts }}" - register: odoo_user_ssh_known_host_results - ignore_errors: yes - changed_when: no - - - name: SSH - Scan hosts public keys - shell: "{{ odoo_ssh_keyscan_cmd}} {{ item.item }} >> {{ odoo_user_ssh_known_hosts_file }}" - when: item.stdout == "" - with_items: "{{ odoo_user_ssh_known_host_results.results }}" - - - name: Set SSH public keys for the Odoo user - authorized_key: - user: "{{ odoo_user }}" - key: "{{ lookup('file', item) }}" - with_fileglob: - - "{{ odoo_user_sshkeys }}" - - become: yes - become_user: "{{ odoo_user }}" diff --git a/tasks/install_standard.yml b/tasks/install_standard.yml deleted file mode 100644 index 016d187..0000000 --- a/tasks/install_standard.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: Install Odoo dependencies - apt: pkg={{ item }} - state=installed - update_cache={{ odoo_apt_update_cache }} - cache_valid_time={{ odoo_apt_cache_valid_time }} - with_items: "{{ odoo_debian_packages }}" - tags: - - odoo_packages - -- name: Install Odoo dependencies (PyPi) - pip: name={{ item }} - with_items: "{{ odoo_pypi_packages }}" - tags: - - odoo_packages - -- import_tasks: config.yml - tags: - - odoo_config diff --git a/tasks/main.yml b/tasks/main.yml deleted file mode 100644 index 9fb9c5f..0000000 --- a/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -- name: Set variables depending on the platform and the version of Odoo - include_vars: "{{ item }}" - with_first_found: - - "../vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version | int}}_Odoo-{{ odoo_version | int }}.yml" - tags: - - always - -- import_tasks: install.yml - tags: - - odoo - - odoo_install - -- import_tasks: wkhtmltox.yml - tags: - - odoo - - odoo_wkhtmltox - -- import_tasks: reportlab.yml - tags: - - odoo - - odoo_reportlab - -- import_tasks: postgresql.yml - tags: - - odoo - - odoo_postgresql - -- import_tasks: service.yml - tags: - - odoo - - odoo_service diff --git a/tasks/postgresql.yml b/tasks/postgresql.yml deleted file mode 100644 index 250c72d..0000000 --- a/tasks/postgresql.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -- name: Delegate PostgreSQL tasks to the relevant host - set_fact: - odoo_postgresql_delegate_to: "{{ odoo_config_db_host if ((odoo_config_db_host|bool) != False) else inventory_hostname }}" - odoo_postgresql_remote_user: "{{ odoo_config_db_host_user if ((odoo_config_db_host|bool) != False) else ansible_user }}" - -- block: - - - name: PostgreSQL - Add the Odoo user - postgresql_user: name={{ odoo_config_db_user }} - role_attr_flags={{ odoo_postgresql_user_role_attr }} - when: odoo_postgresql_set_user - - - name: PostgreSQL - Set the Odoo user password - postgresql_user: name={{ odoo_config_db_user }} - password={{ odoo_config_db_passwd }} - when: odoo_config_db_passwd is defined and odoo_config_db_passwd - and odoo_postgresql_set_user - - - name: PostgreSQL - Activate some extensions on the 'template1' database - postgresql_ext: - name: "{{ item }}" - db: template1 - with_items: "{{ odoo_postgresql_extensions }}" - - delegate_to: "{{ odoo_postgresql_delegate_to }}" - remote_user: "{{ odoo_postgresql_remote_user }}" - become: yes - become_user: postgres diff --git a/tasks/reportlab.yml b/tasks/reportlab.yml deleted file mode 100644 index 19d5248..0000000 --- a/tasks/reportlab.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# Download and install the barcode fonts from ReportLab -- name: Download the ReportLab barcode fonts - get_url: url="{{ odoo_reportlab_font_url }}" - dest="/opt/pfbfer.zip" - -- name: Create the font directory - file: path="/home/{{ odoo_user }}/fonts" state=directory - -- name: Install unzip - apt: name=unzip state=installed - -- name: Unzip the ReportLab fonts - unarchive: src="/opt/pfbfer.zip" - dest="/home/{{ odoo_user }}/fonts" - owner={{ odoo_user }} - group={{ odoo_user }} - mode="u=rwX,go=rX" - copy=No - creates="/home/{{ odoo_user }}/fonts/_abi____.pfb" diff --git a/tasks/service.yml b/tasks/service.yml deleted file mode 100644 index 87e369e..0000000 --- a/tasks/service.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- - -- block: - - name: Generate Odoo init script (standard) - template: src=odoo-{{ odoo_version }}.init dest=/etc/init.d/{{ odoo_service }} - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr != 'systemd' - notify: Restart Odoo - - - name: Generate systemd Odoo service (standard) - template: - src=odoo-standard.service - dest=/etc/systemd/system/{{ odoo_service }}.service - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr == 'systemd' - notify: - - Reload Systemd - - Restart Odoo - when: odoo_install_type == 'standard' - -- block: - - name: Generate Odoo init script (buildout) - template: src=odoo-buildout.init dest=/etc/init.d/{{ odoo_service }} - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr != 'systemd' - notify: Restart Odoo - - - name: Generate systemd Odoo service (buildout) - template: - src=odoo-buildout.service - dest=/etc/systemd/system/{{ odoo_service }}.service - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr == 'systemd' - notify: - - Reload Systemd - - Restart Odoo - when: odoo_install_type == 'buildout' - -- block: - - name: Generate Odoo init script (pip) - template: src=odoo-pip.init dest=/etc/init.d/{{ odoo_service }} - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr != 'systemd' - notify: Restart Odoo - - - name: Generate systemd Odoo service (pip) - template: - src=odoo-pip.service - dest=/etc/systemd/system/{{ odoo_service }}.service - owner=root group=root mode=0755 - force=yes - backup=yes - when: ansible_service_mgr == 'systemd' - notify: - - Reload Systemd - - Restart Odoo - when: odoo_install_type == 'pip' - -- name: Enable Odoo service - service: name={{ odoo_service }} enabled=yes state=started - when: odoo_init == True - -- name: Disable Odoo service - service: name={{ odoo_service }} enabled=no state=stopped - when: odoo_init == False diff --git a/tasks/wkhtmltox.yml b/tasks/wkhtmltox.yml deleted file mode 100644 index 3207417..0000000 --- a/tasks/wkhtmltox.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- - -- name: Detect Debian architecture (i386 or amd64) - set_fact: odoo_debian_arch={{ '64' in ansible_architecture and 'amd64' or 'i386' }} - -- name: Download wkhtmltox - get_url: url={{ item }} - dest={{ odoo_wkhtmltox_dest }} - with_items: "{{ odoo_wkhtmltox_urls }}" - ignore_errors: True - when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False - -# Use to detect that the package was downloaded. -# We can not register the result of the previous task to check this as Ansible -# will flag it as failed as soon as one URL fails (even if the download has -# worked on a further URL) -- name: Check wkhtmltox package - stat: path={{ odoo_wkhtmltox_dest }} - register: odoo_wkhtmltox_pkg - -- name: Install wkhtmltox dependencies - apt: pkg={{ item }} - with_items: "{{ odoo_wkhtmltox_depends }}" - when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists - -- name: Install wkhtmltox (Debian package) - apt: - deb: "{{ odoo_wkhtmltox_dest }}" - force: yes - when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists and odoo_wkhtmltox_pkg.stat.mimetype in ['application/x-debian-package', 'application/vnd.debian.binary-package'] - -- name: Install wkhtmltox (generic package) - unarchive: - remote_src: yes - src: "{{ odoo_wkhtmltox_dest }}" - dest: /usr/local - extra_opts: "--strip-components=1" - creates: /usr/local/bin/wkhtmltopdf - when: odoo_wkhtmltox_version is defined and odoo_wkhtmltox_version != False and odoo_wkhtmltox_pkg.stat.exists and odoo_wkhtmltox_pkg.stat.mimetype == 'application/x-xz' diff --git a/templates/odoo-10.0-pip-requirements.txt b/templates/odoo-10.0-pip-requirements.txt deleted file mode 100644 index ec2ba48..0000000 --- a/templates/odoo-10.0-pip-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -https://nightly.odoo.com/10.0/nightly/src/odoo_10.0.latest.zip --e git+https://github.com/OCA/server-tools.git@10.0#egg=odoo10_addon_date_range&subdirectory=setup/date_range diff --git a/templates/odoo-10.0.conf b/templates/odoo-10.0.conf deleted file mode 100644 index 88cd16a..0000000 --- a/templates/odoo-10.0.conf +++ /dev/null @@ -1,64 +0,0 @@ -[options] -{% if odoo_install_type == 'pip' %} -addons_path = -{% else %} -addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }} -{% endif %} -admin_passwd = {{ odoo_config_admin_passwd }} -csv_internal_sep = {{ odoo_config_csv_internal_sep }} -data_dir = {{ odoo_config_data_dir }} -db_host = {{ odoo_config_db_host not in [False, 'localhost', '127.0.0.1'] and odoo_config_db_host in hostvars and hostvars[odoo_config_db_host].get('ansible_host') or odoo_config_db_host }} -db_maxconn = {{ odoo_config_db_maxconn }} -db_name = {{ odoo_config_db_name }} -db_password = {{ odoo_config_db_passwd }} -db_port = {{ odoo_config_db_port }} -db_template = {{ odoo_config_db_template }} -db_user = {{ odoo_config_db_user }} -dbfilter = {{ odoo_config_dbfilter }} -demo = {} -email_from = {{ odoo_config_email_from }} -geoip_database = {{ odoo_config_geoip_database }} -import_partial = -limit_memory_hard = {{ odoo_config_limit_memory_hard }} -limit_memory_soft = {{ odoo_config_limit_memory_soft }} -limit_request = 8192 -limit_time_cpu = {{ odoo_config_limit_time_cpu }} -limit_time_real = {{ odoo_config_limit_time_real }} -limit_time_real_cron = {{ odoo_config_limit_time_real_cron }} -list_db = {{ odoo_config_list_db }} -log_db = {{ odoo_config_log_db }} -log_db_level = warning -log_handler = :INFO -log_level = {{ odoo_config_log_level }} -logfile = {{ odoo_config_logfile }} -logrotate = {{ odoo_config_logrotate }} -longpolling_port = {{ odoo_config_longpolling_port }} -max_cron_threads = {{ odoo_config_max_cron_threads }} -osv_memory_age_limit = {{ odoo_config_osv_memory_age_limit }} -osv_memory_count_limit = {{ odoo_config_osv_memory_count_limit }} -pg_path = None -pidfile = {{ odoo_config_pidfile }} -proxy_mode = {{ odoo_config_proxy_mode }} -reportgz = False -server_wide_modules = {{ odoo_config_server_wide_modules }} -smtp_password = {{ odoo_config_smtp_password }} -smtp_port = {{ odoo_config_smtp_port }} -smtp_server = {{ odoo_config_smtp_server }} -smtp_ssl = {{ odoo_config_smtp_ssl }} -smtp_user = {{ odoo_config_smtp_user }} -syslog = {{ odoo_config_syslog }} -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = {{ odoo_config_translate_modules }} -unaccent = {{ odoo_config_unaccent }} -without_demo = {{ odoo_config_without_demo }} -workers = {{ odoo_config_workers }} -xmlrpc = {{ odoo_config_xmlrpc }} -xmlrpc_interface = {{ odoo_config_xmlrpc_interface }} -xmlrpc_port = {{ odoo_config_xmlrpc_port }} -{% for name in odoo_config_custom | sort %} -{{ name }} = {{ odoo_config_custom[name] }} -{% endfor %} - diff --git a/templates/odoo-10.0.conf.orig b/templates/odoo-10.0.conf.orig deleted file mode 100644 index 471f9fc..0000000 --- a/templates/odoo-10.0.conf.orig +++ /dev/null @@ -1,57 +0,0 @@ -[options] -addons_path = /home/odoo/odoo/parts/odoo/odoo/addons,/home/odoo/odoo/parts/odoo/addons -admin_passwd = admin -csv_internal_sep = , -data_dir = /home/odoo/.local/share/Odoo -db_host = False -db_maxconn = 64 -db_name = False -db_password = False -db_port = False -db_template = template1 -db_user = False -dbfilter = .* -demo = {} -email_from = False -geoip_database = /usr/share/GeoIP/GeoLiteCity.dat -import_partial = -limit_memory_hard = 2684354560 -limit_memory_soft = 2147483648 -limit_request = 8192 -limit_time_cpu = 60 -limit_time_real = 120 -limit_time_real_cron = -1 -list_db = True -log_db = False -log_db_level = warning -log_handler = :INFO -log_level = info -logfile = None -logrotate = False -longpolling_port = 8072 -max_cron_threads = 2 -osv_memory_age_limit = 1.0 -osv_memory_count_limit = False -pg_path = None -pidfile = None -proxy_mode = False -reportgz = False -server_wide_modules = web,web_kanban -smtp_password = False -smtp_port = 25 -smtp_server = localhost -smtp_ssl = False -smtp_user = False -syslog = False -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = ['all'] -unaccent = False -without_demo = False -workers = 0 -xmlrpc = True -xmlrpc_interface = -xmlrpc_port = 8069 - diff --git a/templates/odoo-10.0.init b/templates/odoo-10.0.init deleted file mode 100644 index 1b9a7a7..0000000 --- a/templates/odoo-10.0.init +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: {{ odoo_service }} -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: $network -# Should-Stop: $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start odoo daemon at boot time -# Description: Enable service provided by daemon. -### END INIT INFO -## more info: http://wiki.debian.org/LSBInitScripts - -. /lib/lsb/init-functions - -PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin -WORKDIR={{ odoo_workdir }} -DAEMON={{ odoo_rootdir }}/odoo-bin -NAME={{ odoo_service }} -DESC={{ odoo_service }} -CONFIG={{ odoo_config_file }} -LOGFILE={{ odoo_logfile }} -PIDFILE=/var/run/${NAME}.pid -USER={{ odoo_user }} -export LOGNAME=$USER -{% if odoo_init_env %} -# Custom environment variables -{% for name, value in odoo_init_env.iteritems() %} -export {{ name }}={{ value }} -{% endfor %} -{% endif %} - -test -x $DAEMON || exit 0 -set -e - -function _start() { - start-stop-daemon --chdir=${WORKDIR} --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE -} - -function _stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3 - rm -f $PIDFILE -} - -function _status() { - start-stop-daemon --status --quiet --pidfile $PIDFILE - return $? -} - - -case "$1" in - start) - echo -n "Starting $DESC: " - _start - echo "ok" - ;; - stop) - echo -n "Stopping $DESC: " - _stop - echo "ok" - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - _stop - sleep 1 - _start - echo "ok" - ;; - status) - echo -n "Status of $DESC: " - _status && echo "running" || echo "stopped" - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/templates/odoo-11.0-pip-requirements.txt b/templates/odoo-11.0-pip-requirements.txt deleted file mode 100644 index 2db5b98..0000000 --- a/templates/odoo-11.0-pip-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -https://nightly.odoo.com/11.0/nightly/src/odoo_11.0.latest.zip --e git+https://github.com/OCA/server-ux.git@11.0#egg=odoo11_addon_date_range&subdirectory=setup/date_range diff --git a/templates/odoo-11.0.conf b/templates/odoo-11.0.conf deleted file mode 100644 index bf2ff64..0000000 --- a/templates/odoo-11.0.conf +++ /dev/null @@ -1,65 +0,0 @@ -[options] -{% if odoo_install_type == 'pip' %} -addons_path = -{% else %} -addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }} -{% endif %} -admin_passwd = {{ odoo_config_admin_passwd }} -csv_internal_sep = {{ odoo_config_csv_internal_sep }} -data_dir = {{ odoo_config_data_dir }} -db_host = {{ odoo_config_db_host not in [False, 'localhost', '127.0.0.1'] and odoo_config_db_host in hostvars and hostvars[odoo_config_db_host].get('ansible_host') or odoo_config_db_host }} -db_maxconn = {{ odoo_config_db_maxconn }} -db_name = {{ odoo_config_db_name }} -db_password = {{ odoo_config_db_passwd }} -db_port = {{ odoo_config_db_port }} -db_sslmode = {{ odoo_config_db_sslmode }} -db_template = {{ odoo_config_db_template }} -db_user = {{ odoo_config_db_user }} -dbfilter = {{ odoo_config_dbfilter }} -demo = {} -email_from = {{ odoo_config_email_from }} -geoip_database = {{ odoo_config_geoip_database }} -http_enable = {{ odoo_config_http_enable or odoo_config_xmlrpc }} -http_interface = {{ odoo_config_http_interface or odoo_config_xmlrpc_interface }} -http_port = {{ odoo_config_http_port or odoo_config_xmlrpc_port }} -import_partial = -limit_memory_hard = {{ odoo_config_limit_memory_hard }} -limit_memory_soft = {{ odoo_config_limit_memory_soft }} -limit_request = 8192 -limit_time_cpu = {{ odoo_config_limit_time_cpu }} -limit_time_real = {{ odoo_config_limit_time_real }} -limit_time_real_cron = {{ odoo_config_limit_time_real_cron }} -list_db = {{ odoo_config_list_db }} -log_db = {{ odoo_config_log_db }} -log_db_level = warning -log_handler = :INFO -log_level = {{ odoo_config_log_level }} -logfile = {{ odoo_config_logfile }} -logrotate = {{ odoo_config_logrotate }} -longpolling_port = {{ odoo_config_longpolling_port }} -max_cron_threads = {{ odoo_config_max_cron_threads }} -osv_memory_age_limit = {{ odoo_config_osv_memory_age_limit }} -osv_memory_count_limit = {{ odoo_config_osv_memory_count_limit }} -pg_path = None -pidfile = {{ odoo_config_pidfile }} -proxy_mode = {{ odoo_config_proxy_mode }} -reportgz = False -server_wide_modules = {{ odoo_config_server_wide_modules }} -smtp_password = {{ odoo_config_smtp_password }} -smtp_port = {{ odoo_config_smtp_port }} -smtp_server = {{ odoo_config_smtp_server }} -smtp_ssl = {{ odoo_config_smtp_ssl }} -smtp_user = {{ odoo_config_smtp_user }} -syslog = {{ odoo_config_syslog }} -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = {{ odoo_config_translate_modules }} -unaccent = {{ odoo_config_unaccent }} -without_demo = {{ odoo_config_without_demo }} -workers = {{ odoo_config_workers }} -{% for name in odoo_config_custom | sort %} -{{ name }} = {{ odoo_config_custom[name] }} -{% endfor %} - diff --git a/templates/odoo-11.0.conf.orig b/templates/odoo-11.0.conf.orig deleted file mode 100644 index 884cf0b..0000000 --- a/templates/odoo-11.0.conf.orig +++ /dev/null @@ -1,58 +0,0 @@ -[options] -addons_path = /home/odoo/odoo/parts/odoo/odoo/addons,/home/odoo/odoo/parts/odoo/addons -admin_passwd = admin -csv_internal_sep = , -data_dir = /home/odoo/.local/share/Odoo -db_host = False -db_maxconn = 64 -db_name = False -db_password = False -db_port = False -db_sslmode = prefer -db_template = template1 -db_user = False -dbfilter = .* -demo = {} -email_from = False -geoip_database = /usr/share/GeoIP/GeoLiteCity.dat -http_enable = True -http_interface = -http_port = 8069 -import_partial = -limit_memory_hard = 2684354560 -limit_memory_soft = 2147483648 -limit_request = 8192 -limit_time_cpu = 60 -limit_time_real = 120 -limit_time_real_cron = -1 -list_db = True -log_db = False -log_db_level = warning -log_handler = :INFO -log_level = info -logfile = None -logrotate = False -longpolling_port = 8072 -max_cron_threads = 2 -osv_memory_age_limit = 1.0 -osv_memory_count_limit = False -pg_path = None -pidfile = None -proxy_mode = False -reportgz = False -server_wide_modules = web -smtp_password = False -smtp_port = 25 -smtp_server = localhost -smtp_ssl = False -smtp_user = False -syslog = False -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = ['all'] -unaccent = False -without_demo = False -workers = 0 - diff --git a/templates/odoo-11.0.init b/templates/odoo-11.0.init deleted file mode 120000 index 5cb1712..0000000 --- a/templates/odoo-11.0.init +++ /dev/null @@ -1 +0,0 @@ -odoo-10.0.init \ No newline at end of file diff --git a/templates/odoo-8.0-pip-requirements.txt b/templates/odoo-8.0-pip-requirements.txt deleted file mode 100644 index df2942c..0000000 --- a/templates/odoo-8.0-pip-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -https://nightly.odoo.com/8.0/nightly/src/odoo_8.0.latest.zip diff --git a/templates/odoo-8.0.conf b/templates/odoo-8.0.conf deleted file mode 100644 index b7f1fc7..0000000 --- a/templates/odoo-8.0.conf +++ /dev/null @@ -1,70 +0,0 @@ -[options] -{% if odoo_install_type == 'pip' %} -addons_path = -{% else %} -addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }} -{% endif %} -admin_passwd = {{ odoo_config_admin_passwd }} -auto_reload = {{ odoo_config_auto_reload }} -csv_internal_sep = {{ odoo_config_csv_internal_sep }} -data_dir = {{ odoo_config_data_dir }} -db_host = {{ odoo_config_db_host not in [False, 'localhost', '127.0.0.1'] and odoo_config_db_host in hostvars and hostvars[odoo_config_db_host].get('ansible_host') or odoo_config_db_host }} -db_maxconn = {{ odoo_config_db_maxconn }} -db_name = {{ odoo_config_db_name }} -db_password = {{ odoo_config_db_passwd }} -db_port = {{ odoo_config_db_port }} -db_template = {{ odoo_config_db_template }} -db_user = {{ odoo_config_db_user }} -dbfilter = {{ odoo_config_dbfilter }} -debug_mode = {{ odoo_config_debug_mode }} -demo = {} -email_from = {{ odoo_config_email_from }} -geoip_database = {{ odoo_config_geoip_database }} -import_partial = -limit_memory_hard = {{ odoo_config_limit_memory_hard }} -limit_memory_soft = {{ odoo_config_limit_memory_soft }} -limit_request = 8192 -limit_time_cpu = {{ odoo_config_limit_time_cpu }} -limit_time_real = {{ odoo_config_limit_time_real }} -list_db = {{ odoo_config_list_db }} -log_db = {{ odoo_config_log_db }} -log_handler = [':INFO'] -log_level = {{ odoo_config_log_level }} -logfile = {{ odoo_config_logfile }} -logrotate = {{ odoo_config_logrotate }} -longpolling_port = {{ odoo_config_longpolling_port }} -max_cron_threads = {{ odoo_config_max_cron_threads }} -osv_memory_age_limit = {{ odoo_config_osv_memory_age_limit }} -osv_memory_count_limit = {{ odoo_config_osv_memory_count_limit }} -pg_path = None -pidfile = {{ odoo_config_pidfile }} -proxy_mode = {{ odoo_config_proxy_mode }} -reportgz = False -secure_cert_file = {{ odoo_config_secure_cert_file }} -secure_pkey_file = {{ odoo_config_secure_pkey_file }} -server_wide_modules = {{ odoo_config_server_wide_modules }} -smtp_password = {{ odoo_config_smtp_password }} -smtp_port = {{ odoo_config_smtp_port }} -smtp_server = {{ odoo_config_smtp_server }} -smtp_ssl = {{ odoo_config_smtp_ssl }} -smtp_user = {{ odoo_config_smtp_user }} -syslog = {{ odoo_config_syslog }} -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -timezone = {{ odoo_config_timezone }} -translate_modules = {{ odoo_config_translate_modules }} -unaccent = {{ odoo_config_unaccent }} -without_demo = {{ odoo_config_without_demo }} -workers = {{ odoo_config_workers }} -xmlrpc = {{ odoo_config_xmlrpc }} -xmlrpc_interface = {{ odoo_config_xmlrpc_interface }} -xmlrpc_port = {{ odoo_config_xmlrpc_port }} -xmlrpcs = {{ odoo_config_xmlrpcs }} -xmlrpcs_interface = {{ odoo_config_xmlrpcs_interface }} -xmlrpcs_port = {{ odoo_config_xmlrpcs_port }} -{% for name in odoo_config_custom | sort %} -{{ name }} = {{ odoo_config_custom[name] }} -{% endfor %} - diff --git a/templates/odoo-8.0.init b/templates/odoo-8.0.init deleted file mode 100644 index 322e1a8..0000000 --- a/templates/odoo-8.0.init +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: {{ odoo_service }} -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: $network -# Should-Stop: $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start odoo daemon at boot time -# Description: Enable service provided by daemon. -### END INIT INFO -## more info: http://wiki.debian.org/LSBInitScripts - -. /lib/lsb/init-functions - -PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin -WORKDIR={{ odoo_workdir }} -DAEMON={{ odoo_rootdir }}/odoo.py -NAME={{ odoo_service }} -DESC={{ odoo_service }} -CONFIG={{ odoo_config_file }} -LOGFILE={{ odoo_logfile }} -PIDFILE=/var/run/${NAME}.pid -USER={{ odoo_user }} -export LOGNAME=$USER -{% if odoo_init_env %} -# Custom environment variables -{% for name, value in odoo_init_env.iteritems() %} -export {{ name }}={{ value }} -{% endfor %} -{% endif %} - -test -x $DAEMON || exit 0 -set -e - -function _start() { - start-stop-daemon --chdir=${WORKDIR} --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE{{ odoo_config_server_wide_modules not in [False, 'None', ''] and ' --load=%s' % odoo_config_server_wide_modules or '' }} -} - -function _stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3 - rm -f $PIDFILE -} - -function _status() { - start-stop-daemon --status --quiet --pidfile $PIDFILE - return $? -} - - -case "$1" in - start) - echo -n "Starting $DESC: " - _start - echo "ok" - ;; - stop) - echo -n "Stopping $DESC: " - _stop - echo "ok" - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - _stop - sleep 1 - _start - echo "ok" - ;; - status) - echo -n "Status of $DESC: " - _status && echo "running" || echo "stopped" - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/templates/odoo-9.0-pip-requirements.txt b/templates/odoo-9.0-pip-requirements.txt deleted file mode 100644 index 17de28b..0000000 --- a/templates/odoo-9.0-pip-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -https://nightly.odoo.com/9.0/nightly/src/odoo_9.0.latest.zip diff --git a/templates/odoo-9.0.conf b/templates/odoo-9.0.conf deleted file mode 100644 index dfc21eb..0000000 --- a/templates/odoo-9.0.conf +++ /dev/null @@ -1,65 +0,0 @@ -[options] -{% if odoo_install_type == 'pip' %} -addons_path = -{% else %} -addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }} -{% endif %} -admin_passwd = {{ odoo_config_admin_passwd }} -csv_internal_sep = {{ odoo_config_csv_internal_sep }} -data_dir = {{ odoo_config_data_dir }} -db_host = {{ odoo_config_db_host not in [False, 'localhost', '127.0.0.1'] and odoo_config_db_host in hostvars and hostvars[odoo_config_db_host].get('ansible_host') or odoo_config_db_host }} -db_maxconn = {{ odoo_config_db_maxconn }} -db_name = {{ odoo_config_db_name }} -db_password = {{ odoo_config_db_passwd }} -db_port = {{ odoo_config_db_port }} -db_template = {{ odoo_config_db_template }} -db_user = {{ odoo_config_db_user }} -dbfilter = {{ odoo_config_dbfilter }} -debug_mode = {{ odoo_config_debug_mode }} -demo = {} -dev_mode = False -email_from = {{ odoo_config_email_from }} -geoip_database = {{ odoo_config_geoip_database }} -import_partial = -limit_memory_hard = {{ odoo_config_limit_memory_hard }} -limit_memory_soft = {{ odoo_config_limit_memory_soft }} -limit_request = 8192 -limit_time_cpu = {{ odoo_config_limit_time_cpu }} -limit_time_real = {{ odoo_config_limit_time_real }} -list_db = {{ odoo_config_list_db }} -log_db = {{ odoo_config_log_db }} -log_db_level = warning -log_handler = :INFO -log_level = {{ odoo_config_log_level }} -logfile = {{ odoo_config_logfile }} -logrotate = {{ odoo_config_logrotate }} -longpolling_port = {{ odoo_config_longpolling_port }} -max_cron_threads = {{ odoo_config_max_cron_threads }} -osv_memory_age_limit = {{ odoo_config_osv_memory_age_limit }} -osv_memory_count_limit = {{ odoo_config_osv_memory_count_limit }} -pg_path = None -pidfile = {{ odoo_config_pidfile }} -proxy_mode = {{ odoo_config_proxy_mode }} -reportgz = False -server_wide_modules = {{ odoo_config_server_wide_modules }} -smtp_password = {{ odoo_config_smtp_password }} -smtp_port = {{ odoo_config_smtp_port }} -smtp_server = {{ odoo_config_smtp_server }} -smtp_ssl = {{ odoo_config_smtp_ssl }} -smtp_user = {{ odoo_config_smtp_user }} -syslog = {{ odoo_config_syslog }} -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = {{ odoo_config_translate_modules }} -unaccent = {{ odoo_config_unaccent }} -without_demo = {{ odoo_config_without_demo }} -workers = {{ odoo_config_workers }} -xmlrpc = {{ odoo_config_xmlrpc }} -xmlrpc_interface = {{ odoo_config_xmlrpc_interface }} -xmlrpc_port = {{ odoo_config_xmlrpc_port }} -{% for name in odoo_config_custom | sort %} -{{ name }} = {{ odoo_config_custom[name] }} -{% endfor %} - diff --git a/templates/odoo-9.0.conf.orig b/templates/odoo-9.0.conf.orig deleted file mode 100644 index 11b871c..0000000 --- a/templates/odoo-9.0.conf.orig +++ /dev/null @@ -1,58 +0,0 @@ -[options] -addons_path = /home/odoo/odoo-9.0/openerp/addons,/home/odoo/odoo-9.0/addons -admin_passwd = admin -csv_internal_sep = , -data_dir = /home/odoo/.local/share/Odoo -db_host = False -db_maxconn = 64 -db_name = False -db_password = False -db_port = False -db_template = template1 -db_user = False -dbfilter = .* -debug_mode = False -demo = {} -dev_mode = False -email_from = False -geoip_database = /usr/share/GeoIP/GeoLiteCity.dat -import_partial = -limit_memory_hard = 2684354560 -limit_memory_soft = 2147483648 -limit_request = 8192 -limit_time_cpu = 60 -limit_time_real = 120 -list_db = True -log_db = False -log_db_level = warning -log_handler = :INFO -log_level = info -logfile = None -logrotate = False -longpolling_port = 8072 -max_cron_threads = 2 -osv_memory_age_limit = 1.0 -osv_memory_count_limit = False -pg_path = None -pidfile = None -proxy_mode = False -reportgz = False -server_wide_modules = None -smtp_password = False -smtp_port = 25 -smtp_server = localhost -smtp_ssl = False -smtp_user = False -syslog = False -test_commit = False -test_enable = False -test_file = False -test_report_directory = False -translate_modules = ['all'] -unaccent = False -without_demo = False -workers = 0 -xmlrpc = True -xmlrpc_interface = -xmlrpc_port = 8069 - diff --git a/templates/odoo-9.0.init b/templates/odoo-9.0.init deleted file mode 100644 index 322e1a8..0000000 --- a/templates/odoo-9.0.init +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: {{ odoo_service }} -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: $network -# Should-Stop: $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start odoo daemon at boot time -# Description: Enable service provided by daemon. -### END INIT INFO -## more info: http://wiki.debian.org/LSBInitScripts - -. /lib/lsb/init-functions - -PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin -WORKDIR={{ odoo_workdir }} -DAEMON={{ odoo_rootdir }}/odoo.py -NAME={{ odoo_service }} -DESC={{ odoo_service }} -CONFIG={{ odoo_config_file }} -LOGFILE={{ odoo_logfile }} -PIDFILE=/var/run/${NAME}.pid -USER={{ odoo_user }} -export LOGNAME=$USER -{% if odoo_init_env %} -# Custom environment variables -{% for name, value in odoo_init_env.iteritems() %} -export {{ name }}={{ value }} -{% endfor %} -{% endif %} - -test -x $DAEMON || exit 0 -set -e - -function _start() { - start-stop-daemon --chdir=${WORKDIR} --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE{{ odoo_config_server_wide_modules not in [False, 'None', ''] and ' --load=%s' % odoo_config_server_wide_modules or '' }} -} - -function _stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3 - rm -f $PIDFILE -} - -function _status() { - start-stop-daemon --status --quiet --pidfile $PIDFILE - return $? -} - - -case "$1" in - start) - echo -n "Starting $DESC: " - _start - echo "ok" - ;; - stop) - echo -n "Stopping $DESC: " - _stop - echo "ok" - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - _stop - sleep 1 - _start - echo "ok" - ;; - status) - echo -n "Status of $DESC: " - _status && echo "running" || echo "stopped" - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/templates/odoo-pip.init b/templates/odoo-pip.init deleted file mode 100644 index 7cacea6..0000000 --- a/templates/odoo-pip.init +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: {{ odoo_service }} -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: $network -# Should-Stop: $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start odoo daemon at boot time -# Description: Enable service provided by daemon. -### END INIT INFO -## more info: http://wiki.debian.org/LSBInitScripts - -. /lib/lsb/init-functions - -PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin -WORKDIR={{ odoo_workdir }} -VIRTUALENV={{ odoo_pip_venv_path }} -DAEMON={{ odoo_pip_odoo_bin_path }} -NAME={{ odoo_service }} -DESC={{ odoo_service }} -CONFIG={{ odoo_config_file }} -LOGFILE={{ odoo_logfile }} -PIDFILE=/var/run/${NAME}.pid -USER={{ odoo_user }} -export LOGNAME=$USER -{% if odoo_init_env %} -# Custom environment variables -{% for name, value in odoo_init_env.iteritems() %} -export {{ name }}={{ value }} -{% endfor %} -{% endif %} - -test -x $DAEMON || exit 0 -set -e - -function _start() { - . $VIRTUALENV/bin/activate - # '--load' is used here as Odoo ignores the 'server_wide_modules' option - # from the configuration file - # Odoo: https://github.com/odoo/odoo/pull/13685 - # OCB: https://github.com/OCA/OCB/pull/553 - start-stop-daemon --chdir=${WORKDIR} --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE{{ odoo_config_server_wide_modules not in [False, 'None', ''] and ' --load=%s' % odoo_config_server_wide_modules or '' }} -} - -function _stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3 - rm -f $PIDFILE -} - -function _status() { - start-stop-daemon --status --quiet --pidfile $PIDFILE - return $? -} - - -case "$1" in - start) - echo -n "Starting $DESC: " - _start - echo "ok" - ;; - stop) - echo -n "Stopping $DESC: " - _stop - echo "ok" - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - _stop - sleep 1 - _start - echo "ok" - ;; - status) - echo -n "Status of $DESC: " - _status && echo "running" || echo "stopped" - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac - -exit 0 - diff --git a/templates/odoo-pip.service b/templates/odoo-pip.service deleted file mode 100644 index 23ce52b..0000000 --- a/templates/odoo-pip.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description={{ odoo_service }} -After=network.target - -[Service] -Type=simple -User={{ odoo_user }} -WorkingDirectory={{ odoo_workdir }} -ExecStart={{ odoo_pip_odoo_bin_path }}{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }} -KillMode=mixed -{% for name, value in odoo_init_env.iteritems() %} -Environment={{ name }}={{ value }} -{% endfor %} - -[Install] -WantedBy=multi-user.target diff --git a/templates/odoo-standard.service b/templates/odoo-standard.service deleted file mode 100644 index e4ad3e7..0000000 --- a/templates/odoo-standard.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description={{ odoo_service }} -After=network.target - -[Service] -Type=simple -User={{ odoo_user }} -WorkingDirectory={{ odoo_workdir }} -{% if odoo_version | version_compare('10.0', '>=') %} -ExecStart={{ odoo_rootdir }}/odoo-bin{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }} -KillMode=mixed -{% else %} -ExecStart={{ odoo_rootdir }}/odoo.py{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }} -{% endif %} -{% for name, value in odoo_init_env.iteritems() %} -Environment={{ name }}={{ value }} -{% endfor %} - -[Install] -WantedBy=multi-user.target diff --git a/tests/install_test_env.sh b/tests/install_test_env.sh deleted file mode 100755 index 43a389b..0000000 --- a/tests/install_test_env.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -HERE=$(dirname $(readlink -m $0)) -VENV=/opt/ansible-venv -GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py" -# Install system dependencies -apt-get update -qq -apt-get install -qq python-virtualenv python-apt python-pip python-dev lsb-release wget ca-certificates -# Install Ansible in a virtual Python environment -virtualenv $VENV -wget $GET_PIP_URL -O $VENV/get-pip.py -$VENV/bin/python $VENV/get-pip.py -$VENV/bin/pip install "ansible>=$ANSIBLE_VERSION" -# Install PostgreSQL -apt-get install -qq postgresql postgresql-contrib diff --git a/tests/inventory b/tests/inventory deleted file mode 100644 index 2fbb50c..0000000 --- a/tests/inventory +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/tests/run.sh b/tests/run.sh deleted file mode 100755 index 3a9eb31..0000000 --- a/tests/run.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -HERE=$(dirname $(readlink -m $0)) -VENV=/opt/ansible-venv -CMD="$VENV/bin/ansible-playbook -i tests/inventory" -cd $HERE/.. -# Configure environment -export PAGER=cat -# Configure Ansible -cat < ansible.cfg -[defaults] -roles_path = ../ -[ssh_connection] -pipelining=True -EOF -echo "== CHECK THE ROLE/PLAYBOOK'S SYNTAX ==" -$CMD tests/test_$ODOO_INSTALL_TYPE.yml --syntax-check || exit 1 - -echo "== RUN THE ROLE/PLAYBOOK WITH ANSIBLE-PLAYBOOK ==" -$CMD tests/test_$ODOO_INSTALL_TYPE.yml --connection=local --become -e "odoo_version=$ODOO_VERSION" || exit 1 -echo "== CHECK THE SERVICE STATUS ==" -sudo -E service odoo-$ODOO_INSTALL_TYPE status || exit 1 - -echo "== RUN THE ROLE/PLAYBOOK AGAIN, CHECKING TO MAKE SURE IT'S IDEMPOTENT ==" -output_log=$ODOO_VERSION_$ODOO_INSTALL_TYPE.log -$CMD tests/test_${ODOO_INSTALL_TYPE}.yml --connection=local --become -e "odoo_version=$ODOO_VERSION" -v > $output_log || exit 1 -grep -q 'changed=0.*failed=0' $output_log \ - && (echo 'IDEMPOTENCE TEST: OK' && exit 0) \ - || (echo 'IDEMPOTENCE TEST: FAILED' && cat $output_log && exit 1) || exit 1 -echo "== CHECK THE SERVICE STATUS ==" -sudo -E service odoo-$ODOO_INSTALL_TYPE status || exit 1 - -echo "== RUN THE ROLE/PLAYBOOK AGAIN BUT CHANGE THE CONFIGURATION AND CHECK IF THE SERVICE RESTART ==" -$CMD tests/test_${ODOO_INSTALL_TYPE}_changed.yml --connection=local --become -e "odoo_version=$ODOO_VERSION" -v > $output_log || exit 1 -grep -q 'changed=2.*failed=0' $output_log \ - && (echo 'RESTART TEST: OK' && exit 0) \ - || (echo 'RESTART TEST: FAILED' && cat $output_log && exit 1) || exit 1 - -echo "== CHECK THE SERVICE STATUS ==" -sudo -E service odoo-$ODOO_INSTALL_TYPE status || exit 1 -sleep 3 && if ! wget http://localhost:8069; then tail -n 100 /var/log/odoo/*.log && exit 1; fi -sudo -E service odoo-$ODOO_INSTALL_TYPE stop || exit 1 - -echo "== CHECK WKHTMLTOPDF ==" -wkhtmltopdf --version diff --git a/tests/test_buildout.yml b/tests/test_buildout.yml deleted file mode 100644 index 37dcd03..0000000 --- a/tests/test_buildout.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: buildout - odoo_service: odoo-buildout diff --git a/tests/test_buildout_changed.yml b/tests/test_buildout_changed.yml deleted file mode 100644 index 89d4db9..0000000 --- a/tests/test_buildout_changed.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: buildout - odoo_service: odoo-buildout - odoo_init_env: - CHANGED_TEST: 1 diff --git a/tests/test_pip.yml b/tests/test_pip.yml deleted file mode 100644 index 709bb57..0000000 --- a/tests/test_pip.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: pip - odoo_service: odoo-pip - environment: - LC_ALL: en_US.UTF-8 diff --git a/tests/test_pip_changed.yml b/tests/test_pip_changed.yml deleted file mode 100644 index 4696b71..0000000 --- a/tests/test_pip_changed.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: pip - odoo_service: odoo-pip - odoo_init_env: - CHANGED_TEST: 1 - environment: - LC_ALL: en_US.UTF-8 diff --git a/tests/test_standard.yml b/tests/test_standard.yml deleted file mode 100644 index dc09f17..0000000 --- a/tests/test_standard.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: standard - odoo_service: odoo-standard diff --git a/tests/test_standard_changed.yml b/tests/test_standard_changed.yml deleted file mode 100644 index cdfbfc8..0000000 --- a/tests/test_standard_changed.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- hosts: localhost - become: yes - roles: - - ansible-odoo - vars: - odoo_install_type: standard - odoo_service: odoo-standard - odoo_init_env: - CHANGED_TEST: 1 diff --git a/tests/travis_lxd/create_container.sh b/tests/travis_lxd/create_container.sh deleted file mode 100755 index 5a9f667..0000000 --- a/tests/travis_lxd/create_container.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -HERE=$(dirname $(readlink -m $0)) -CT_DIR="/var/lib/lxd/containers/$1" -# Spawn a LXD container -lxc init ${IMAGE} $1 -c security.privileged=true -lxc config set $1 raw.lxc "lxc.aa_allow_incomplete=1" -if [[ "$IMAGE" == 'images:debian/jessie' ]]; then - $HERE/fix_debian_jessie.sh $1; -fi -lxc start $1 && sleep 4 && lxc list -# Configure the container -lxc config set $1 environment.ODOO_VERSION $ODOO_VERSION -lxc config set $1 environment.ODOO_INSTALL_TYPE $ODOO_INSTALL_TYPE -lxc config set $1 environment.ANSIBLE_VERSION $ANSIBLE_VERSION -# Copy the project files into the container -cp -av $HERE/../.. $CT_DIR/rootfs/opt/ansible-odoo -# Install the test environment -lxc exec $1 -- sh -c "/opt/ansible-odoo/tests/install_test_env.sh" diff --git a/tests/travis_lxd/fix_debian_jessie.sh b/tests/travis_lxd/fix_debian_jessie.sh deleted file mode 100755 index 3340bd9..0000000 --- a/tests/travis_lxd/fix_debian_jessie.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# This script fix the Debian Jessie container by replacing systemd by SysV -# -CT_DIR="/var/lib/lxd/containers/$1" -ROOTFS="$CT_DIR/rootfs" -UID_GID=$(ls -n $CT_DIR | grep rootfs | cut -d ' ' -f "3-4") -CT_UID=$(echo $UID_GID | cut -d ' ' -f1) -CT_GID=$(echo $UID_GID | cut -d ' ' -f2) -CT_UID_GID="$CT_UID:$CT_GID" -BRIDGE_IP=$(/sbin/ifconfig lxdbr0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') -# Configure the network of the container -echo -e "nameserver $BRIDGE_IP\nsearch lxd" > $ROOTFS/etc/resolv.conf -cat $ROOTFS/etc/resolv.conf -chroot --userspec=$CT_UID_GID $ROOTFS apt-get update -chroot --userspec=$CT_UID_GID $ROOTFS apt-get install -y sysvinit-core -d -chroot $ROOTFS apt-get install -y sysvinit-core -chroot --userspec=$CT_UID_GID $ROOTFS apt-get update -chown $CT_UID_GID $ROOTFS/var/log/apt/term.log -chown $CT_UID_GID $ROOTFS/var/lib/dpkg/status -# Purge the network configuration from the container -rm $ROOTFS/etc/resolv.conf diff --git a/tests/travis_lxd/install.sh b/tests/travis_lxd/install.sh deleted file mode 100755 index f6a0c68..0000000 --- a/tests/travis_lxd/install.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -HERE=$(dirname $(readlink -m $0)) -# Install and configure LXD on Travis-CI -debconf-set-selections $HERE/lxd-debconf -echo 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' > /etc/apt/sources.list.d/backports.list -apt-get -qq update; -apt-get -y install -t trusty-backports ca-certificates lxd; -lxd init --auto -usermod -a -G lxd travis diff --git a/tests/travis_lxd/lxd-debconf b/tests/travis_lxd/lxd-debconf deleted file mode 100644 index 01d8079..0000000 --- a/tests/travis_lxd/lxd-debconf +++ /dev/null @@ -1,22 +0,0 @@ -lxd lxd/bridge-ipv4-address string 10.224.136.1 -lxd lxd/bridge-ipv4-dhcp-leases string 252 -lxd lxd/use-existing-bridge boolean false -lxd lxd/bridge-ipv6-netmask string -lxd lxd/bridge-ipv6 boolean false -lxd lxd/setup-bridge boolean true -lxd lxd/bridge-ipv4-netmask string 24 -lxd lxd/bridge-ipv4 boolean true -lxd lxd/bridge-ipv6-address string -lxd lxd/update-profile boolean true -lxd lxd/bridge-name string lxdbr0 -lxd lxd/bridge-empty-error note -# lxcbr0 is being replaced by lxdbr0 -lxd lxd/bridge-upgrade-warning note -lxd lxd/bridge-ipv6-nat boolean false -lxd lxd/bridge-random-warning note -lxd lxd/bridge-domain string lxd -lxd lxd/bridge-dnsmasq string -lxd lxd/bridge-http-proxy boolean false -lxd lxd/bridge-ipv4-nat boolean true -lxd lxd/bridge-ipv4-dhcp-last string 10.224.136.254 -lxd lxd/bridge-ipv4-dhcp-first string 10.224.136.2 diff --git a/vars/Debian-8_Odoo-10.yml b/vars/Debian-8_Odoo-10.yml deleted file mode 100644 index b189822..0000000 --- a/vars/Debian-8_Odoo-10.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-openssl - - python-markupsafe - - python-serial - - python-usb - - python-qrcode - # Dependencies taken from the deb package - - python-babel - - python-dateutil - - python-decorator - - python-docutils - - python-feedparser - - python-gevent - - python-greenlet - - python-imaging - - python-jinja2 - - python-ldap - - python-libxslt1 - - python-lxml - - python-mako - - python-mock - - python-openid - - python-passlib - - python-psutil - - python-psycopg2 - - python-pychart - - python-pydot - - python-pyparsing - - python-pypdf - - python-reportlab - - python-requests - - python-six - - python-suds - - python-tz - - python-vatnumber - - python-vobject - - python-werkzeug - - python-xlsxwriter - - python-xlwt - - python-yaml - -odoo_nodejs_apt_package: "nodejs=6.*" -odoo_nodejs_apt_repo: "node_6.x" -odoo_npm_packages: - - name: less - version: 2.7.2 - - name: less-plugin-clean-css - version: 1.5.1 - - name: phantomjs-prebuilt - version: 2.1.15 - -odoo_pip_dependencies: - - pip>=9.0.1 - - wrapt - - setuptools>=38.2.3 - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - -odoo_buildout_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.1.2 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - libpng12-0 - - zlib1g - - libssl1.0.0 - - libx11-6 - - libxext6 - - libxrender1 - - libstdc++6 - - libc6 - - libjpeg62-turbo diff --git a/vars/Debian-8_Odoo-8.yml b/vars/Debian-8_Odoo-8.yml deleted file mode 100644 index 19c0c68..0000000 --- a/vars/Debian-8_Odoo-8.yml +++ /dev/null @@ -1,97 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-psycopg2 - - python-simplejson - - python-lxml - - python-tz - - python-imaging - - python-yaml - - python-reportlab - - python-mako - - python-pychart - - python-werkzeug - - python-dateutil - - python-unittest2 - - python-mock - - python-openid - - python-docutils - - python-feedparser - - python-gdata - - python-jinja2 - - python-psutil - - python-pydot - - python-webdav - - python-vatnumber - - python-vobject - - python-xlwt - - python-ldap - - python-openssl - - python-egenix-mxdatetime - - python-zsi - - python-requests - - python-pypdf - - python-decorator - - python-passlib - - python-babel - - python-gevent - -odoo_npm_packages: [] - -odoo_pip_dependencies: - - pip>=9.0.1 - - wrapt - - setuptools>=38.2.3 - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - - -odoo_buildout_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.1.2 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - libpng12-0 - - zlib1g - - libssl1.0.0 - - libx11-6 - - libxext6 - - libxrender1 - - libstdc++6 - - libc6 - - libjpeg62-turbo diff --git a/vars/Debian-8_Odoo-9.yml b/vars/Debian-8_Odoo-9.yml deleted file mode 100644 index 5bc8bd6..0000000 --- a/vars/Debian-8_Odoo-9.yml +++ /dev/null @@ -1,104 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-psycopg2 - - python-simplejson - - python-lxml - - python-tz - - python-imaging - - python-yaml - - python-reportlab - - python-mako - - python-pychart - - python-werkzeug - - python-dateutil - - python-unittest2 - - python-mock - - python-openid - - python-docutils - - python-feedparser - - python-gdata - - python-jinja2 - - python-psutil - - python-pydot - - python-webdav - - python-vatnumber - - python-vobject - - python-xlwt - - python-ldap - - python-openssl - - python-egenix-mxdatetime - - python-zsi - - python-requests - - python-pypdf - - python-decorator - - python-passlib - - python-babel - - python-gevent - -odoo_nodejs_apt_package: "nodejs=0.10*" -odoo_nodejs_apt_repo: "node_0.10" -odoo_npm_packages: - - name: less - version: 2.5.3 - - name: less-plugin-clean-css - version: 1.5.1 - - name: phantomjs-prebuilt - version: 2.1.15 - -odoo_pip_dependencies: - - pip>=9.0.1 - - wrapt - - setuptools>=38.2.3 - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - -odoo_buildout_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.1.2 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - libpng12-0 - - zlib1g - - libssl1.0.0 - - libx11-6 - - libxext6 - - libxrender1 - - libstdc++6 - - libc6 - - libjpeg62-turbo diff --git a/vars/Debian-9_Odoo-10.yml b/vars/Debian-9_Odoo-10.yml deleted file mode 100644 index 3bd1720..0000000 --- a/vars/Debian-9_Odoo-10.yml +++ /dev/null @@ -1,106 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-openssl - - python-markupsafe - - python-serial - - python-usb - - python-qrcode - # Dependencies taken from the deb package - - python-babel - - python-dateutil - - python-decorator - - python-docutils - - python-feedparser - - python-gevent - - python-greenlet - - python-imaging - - python-jinja2 - - python-ldap - - python-libxslt1 - - python-lxml - - python-mako - - python-mock - - python-openid - - python-passlib - - python-psutil - - python-psycopg2 - - python-pychart - - python-pydot - - python-pyparsing - - python-reportlab - - python-requests - - python-six - - python-suds - - python-tz - - python-vatnumber - - python-vobject - - python-werkzeug - - python-xlsxwriter - - python-xlwt - - python-yaml - -odoo_pypi_packages: - - psycogreen - - pyPdf==1.13 - -odoo_nodejs_apt_package: "nodejs=6.*" -odoo_nodejs_apt_repo: "node_6.x" -odoo_npm_packages: - - name: less - version: 2.7.2 - - name: less-plugin-clean-css - version: 1.5.1 - - name: phantomjs-prebuilt - version: 2.1.15 - -odoo_pip_dependencies: - - wrapt - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - -odoo_buildout_build_dependencies: - - virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.4 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - zlib1g - - libx11-6 - - libxext6 - - libxrender1 - - libjpeg62-turbo diff --git a/vars/Debian-9_Odoo-8.yml b/vars/Debian-9_Odoo-8.yml deleted file mode 100644 index 16ac65c..0000000 --- a/vars/Debian-9_Odoo-8.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-psycopg2 - - python-simplejson - - python-lxml - - python-tz - - python-imaging - - python-yaml - - python-reportlab - - python-mako - - python-pychart - - python-werkzeug - - python-dateutil - - python-unittest2 - - python-mock - - python-openid - - python-docutils - - python-feedparser - - python-gdata - - python-jinja2 - - python-psutil - - python-pydot - - python-webdav - - python-vatnumber - - python-vobject - - python-xlwt - - python-ldap - - python-openssl - - python-egenix-mxdatetime - - python-zsi - - python-requests - - python-decorator - - python-passlib - - python-babel - - python-gevent - -odoo_pypi_packages: - - psycogreen - - pyPdf==1.13 - -odoo_npm_packages: [] - -odoo_pip_dependencies: - - wrapt - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - -odoo_buildout_build_dependencies: - - virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.4 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - zlib1g - - libx11-6 - - libxext6 - - libxrender1 - - libjpeg62-turbo diff --git a/vars/Debian-9_Odoo-9.yml b/vars/Debian-9_Odoo-9.yml deleted file mode 100644 index ca5763e..0000000 --- a/vars/Debian-9_Odoo-9.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- - -odoo_debian_packages: - - python-dev - - python-psycopg2 - - python-simplejson - - python-lxml - - python-tz - - python-imaging - - python-yaml - - python-reportlab - - python-mako - - python-pychart - - python-werkzeug - - python-dateutil - - python-unittest2 - - python-mock - - python-openid - - python-docutils - - python-feedparser - - python-gdata - - python-jinja2 - - python-psutil - - python-pydot - - python-webdav - - python-vatnumber - - python-vobject - - python-xlwt - - python-ldap - - python-openssl - - python-egenix-mxdatetime - - python-zsi - - python-requests - - python-decorator - - python-passlib - - python-babel - - python-gevent - -odoo_pypi_packages: - - psycogreen - - pyPdf==1.13 - -odoo_nodejs_apt_package: "nodejs=0.10*" -odoo_nodejs_apt_repo: "node_0.10" -odoo_nodejs_apt_dist: "jessie" -odoo_npm_packages: - - name: less - version: 2.5.3 - - name: less-plugin-clean-css - version: 1.5.1 - - name: phantomjs-prebuilt - version: 2.1.15 - -odoo_pip_dependencies: - - wrapt - - odoo-autodiscover==2.0.0 - - setuptools-odoo==2.0.2.post1 - -odoo_pip_build_dependencies: - - python-virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - - libssl-dev - -odoo_buildout_build_dependencies: - - virtualenv - - build-essential - - python-dev - - libxml2-dev - - libxslt1-dev - - libpq-dev - - libldap2-dev - - libsasl2-dev - - libopenjp2-7-dev - - libjpeg62-turbo-dev - - libtiff5-dev - - libfreetype6-dev - - liblcms2-dev - - libwebp-dev - -odoo_wkhtmltox_version: 0.12.4 - -odoo_wkhtmltox_depends: - - fontconfig - - libfontconfig1 - - libfreetype6 - - zlib1g - - libx11-6 - - libxext6 - - libxrender1 - - libjpeg62-turbo