The default recipe deploys the gitea binary, generates a config file and our custom Kosmos label set. The service runs as a Systemd unit. The pg_db recipe needs to run on the primary PostgreSQL (currently andromeda). The backup recipe is empty for now Refs #147
38 lines
876 B
Ruby
38 lines
876 B
Ruby
#
|
|
# Cookbook:: kosmos_gitea
|
|
# Recipe:: pg_db
|
|
#
|
|
# Copyright:: 2020, Kosmos Developers, All Rights Reserved.
|
|
|
|
gitea_data_bag_item = data_bag_item("credentials", "gitea")
|
|
|
|
postgresql_service = "service[#{postgresql_service_name}]"
|
|
|
|
service postgresql_service do
|
|
supports restart: true, status: true, reload: true
|
|
end
|
|
|
|
postgresql_user "gitea" do
|
|
action :create
|
|
password gitea_data_bag_item["postgresql_password"]
|
|
end
|
|
|
|
postgresql_database "gitea" do
|
|
owner "gitea"
|
|
action :create
|
|
end
|
|
|
|
search(:node, "role:gitea AND chef_environment:#{node.chef_environment}").each do |gitea_server|
|
|
ip = ip_for(gitea_server)
|
|
hostname = gitea_server[:hostname]
|
|
|
|
postgresql_access "gitea #{hostname}" do
|
|
access_type "host"
|
|
access_db "gitea"
|
|
access_user "gitea"
|
|
access_addr "#{ip}/32"
|
|
access_method "md5"
|
|
notifies :reload, postgresql_service, :delayed
|
|
end
|
|
end
|