-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from basecamp/remote-env-file
Copy env files to remote hosts
- Loading branch information
Showing
32 changed files
with
453 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require "tempfile" | ||
|
||
class Kamal::Cli::Env < Kamal::Cli::Base | ||
desc "push", "Push the env file to the remote hosts" | ||
def push | ||
mutating do | ||
on(KAMAL.hosts) do | ||
KAMAL.roles_on(host).each do |role| | ||
role_config = KAMAL.config.role(role) | ||
execute *KAMAL.app(role: role).make_env_directory | ||
upload! StringIO.new(role_config.env_file), role_config.host_env_file_path, mode: 400 | ||
end | ||
end | ||
|
||
on(KAMAL.traefik_hosts) do | ||
execute *KAMAL.traefik.make_env_directory | ||
upload! StringIO.new(KAMAL.traefik.env_file), KAMAL.traefik.host_env_file_path, mode: 400 | ||
end | ||
|
||
on(KAMAL.accessory_hosts) do | ||
KAMAL.accessories_on(host).each do |accessory| | ||
accessory_config = KAMAL.config.accessory(accessory) | ||
execute *KAMAL.accessory(accessory).make_env_directory | ||
upload! StringIO.new(accessory_config.env_file), accessory_config.host_env_file_path, mode: 400 | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc "delete", "Delete the env file from the remote hosts" | ||
def delete | ||
mutating do | ||
on(KAMAL.hosts) do | ||
KAMAL.roles_on(host).each do |role| | ||
role_config = KAMAL.config.role(role) | ||
execute *KAMAL.app(role: role).remove_env_file | ||
end | ||
end | ||
|
||
on(KAMAL.traefik_hosts) do | ||
execute *KAMAL.traefik.remove_env_file | ||
end | ||
|
||
on(KAMAL.accessory_hosts) do | ||
KAMAL.accessories_on(host).each do |accessory| | ||
accessory_config = KAMAL.config.accessory(accessory) | ||
execute *KAMAL.accessory(accessory).remove_env_file | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.