From baa073993643344e9a403c40204a6bf59eb956be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 26 May 2020 15:21:26 +0200 Subject: [PATCH] Add the backup recipe Also move the Gitea data dir to an attribute --- site-cookbooks/kosmos_gitea/attributes/default.rb | 1 + site-cookbooks/kosmos_gitea/metadata.rb | 1 + site-cookbooks/kosmos_gitea/recipes/backup.rb | 6 ++++++ site-cookbooks/kosmos_gitea/recipes/default.rb | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/site-cookbooks/kosmos_gitea/attributes/default.rb b/site-cookbooks/kosmos_gitea/attributes/default.rb index 09bfaf8..90251d8 100644 --- a/site-cookbooks/kosmos_gitea/attributes/default.rb +++ b/site-cookbooks/kosmos_gitea/attributes/default.rb @@ -3,3 +3,4 @@ node.default["kosmos_gitea"]["version"] = gitea_version node.default["kosmos_gitea"]["binary_url"] = "https://dl.gitea.io/gitea/#{gitea_version}/gitea-#{gitea_version}-linux-amd64" node.default["kosmos_gitea"]["binary_checksum"] = "d8d43c13e71596c79b541e85e29defe065b4f70ac5155e6d0212bcfc669e1b9c" node.default["kosmos_gitea"]["nginx"]["domain"] = "gitea.kosmos.org" +node.default["kosmos_gitea"]["working_directory"] = "/var/lib/gitea" diff --git a/site-cookbooks/kosmos_gitea/metadata.rb b/site-cookbooks/kosmos_gitea/metadata.rb index 6582a1c..9ceba2a 100644 --- a/site-cookbooks/kosmos_gitea/metadata.rb +++ b/site-cookbooks/kosmos_gitea/metadata.rb @@ -21,3 +21,4 @@ chef_version '>= 14.0' depends "kosmos-nginx" depends "kosmos-postgresql" +depends "backup" diff --git a/site-cookbooks/kosmos_gitea/recipes/backup.rb b/site-cookbooks/kosmos_gitea/recipes/backup.rb index f4779a6..83704f2 100644 --- a/site-cookbooks/kosmos_gitea/recipes/backup.rb +++ b/site-cookbooks/kosmos_gitea/recipes/backup.rb @@ -23,3 +23,9 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +# +unless node.chef_environment == "development" + # backup the data dir and the config files + node.override["backup"]["archives"]["gitea"] = [node["kosmos_gitea"]["working_directory"]] + include_recipe "backup" +end diff --git a/site-cookbooks/kosmos_gitea/recipes/default.rb b/site-cookbooks/kosmos_gitea/recipes/default.rb index 5f02f09..22bfcdc 100644 --- a/site-cookbooks/kosmos_gitea/recipes/default.rb +++ b/site-cookbooks/kosmos_gitea/recipes/default.rb @@ -28,7 +28,7 @@ include_recipe "kosmos-nginx" domain = node["kosmos_gitea"]["nginx"]["domain"] -working_directory = "/var/lib/gitea" +working_directory = node["kosmos_gitea"]["working_directory"] git_home_directory = "/home/git" config_directory = "/etc/gitea" gitea_binary_path = "/usr/local/bin/gitea"