diff --git a/docker-compose.yml b/docker-compose.yml index ffd64cd..502f9f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,12 +9,13 @@ services: - "traefik.docker.network=traefik" - "traefik.http.routers.autoinstall.entrypoints=websecure" - "traefik.http.routers.autoinstall.tls=true" - - "traefik.http.routers.autoinstall.rule=Host(`zenisntall.install.lan`)" + - "traefik.http.routers.autoinstall.rule=Host(`zeninstall.zen6.info`)" - "traefik.http.services.autoinstall.loadbalancer.server.port=3000" + - "traefik.http.routers.autoinstall.tls.certresolver=le" stdin_open: true tty: true - ports: - - 4000:3000 +# ports: +# - 4000:3000 networks: - traefik diff --git a/src/autogen/app/controllers/engine_controller.rb b/src/autogen/app/controllers/engine_controller.rb index 42f3a54..351fc81 100644 --- a/src/autogen/app/controllers/engine_controller.rb +++ b/src/autogen/app/controllers/engine_controller.rb @@ -21,6 +21,7 @@ class EngineController < ApplicationController if @host.toinstall @host.update({status: "Computer Booting"}) end + @api_uri = get_uri(@site) result = render inline: boot_script, layout: false, content_type: 'text/plain' @host.update({lastbootgenerated: result}) end @@ -37,6 +38,7 @@ class EngineController < ApplicationController @template = @host.installtemplate host = @host @host.update({status: "System Install"}) + @api_uri = get_uri(@site) result = render inline: script, layout: false, content_type: 'text/plain' @host.update({lastinstallgenerated: result}) else @@ -57,6 +59,7 @@ class EngineController < ApplicationController @site = @host.site host = @host @template = @host.installtemplate + @api_uri = get_uri(@site) result = render inline: script, layout: false, content_type: 'text/plain' @host.update({lastpostinstallgenerated: result}) end @@ -100,6 +103,7 @@ class EngineController < ApplicationController @site = @host.site @template = @host.installtemplate host = @host + @api_uri = get_uri(@site) result = render inline: script.content, layout: false, content_type: 'text/plain' end end @@ -118,13 +122,19 @@ class EngineController < ApplicationController # Generate random lusk key random_string=SecureRandom.urlsafe_base64(24) # Create new host - @host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["product"], serial: params["serial"], lusk_key: random_string) + @host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["p"], serial: params["s"], lusk_key: random_string) @host.save! end end # Only allow a list of trusted parameters through. def host_params - params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :install_ip, :filename, :access_ip, :product, :serial) + params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :install_ip, :filename, :access_ip, :product, :serial,:p,:s) end -end + def get_uri(site) + if site.api_url.empty? + return "http://#{site.api_ip}:#{site.api_port}" + else + return site.api_url + end + end diff --git a/src/autogen/app/controllers/hosts_controller.rb b/src/autogen/app/controllers/hosts_controller.rb index b58dd0c..3c87804 100644 --- a/src/autogen/app/controllers/hosts_controller.rb +++ b/src/autogen/app/controllers/hosts_controller.rb @@ -72,6 +72,7 @@ class HostsController < ApplicationController @site = @host.site host = @host @template = @host.installtemplate + @api_uri = get_uri(@site) result = render inline: boot_script, layout: false, content_type: 'text/plain' @host.update({lastbootgenerated: result}) @@ -85,6 +86,7 @@ class HostsController < ApplicationController @site = @host.site host = @host @template = @host.installtemplate + @api_uri = get_uri(@site) result = render inline: script, layout: false, content_type: 'text/plain' @host.update({lastinstallgenerated: result}) end @@ -97,6 +99,7 @@ class HostsController < ApplicationController @ansible = Account.find_by(name: "ansible") @site = @host.site host = @host + @api_uri = get_uri(@site) @template = @host.installtemplate result = render inline: script, layout: false, content_type: 'text/plain' end @@ -112,6 +115,14 @@ class HostsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. + def get_uri(site) + if site.api_url.empty? + return "http://#{site.api_ip}:#{site.api_port}" + else + return site.api_url + end + end + def set_host logger.debug "#{params}" @host = Host.find(params[:id]) diff --git a/src/autogen/app/controllers/sites_controller.rb b/src/autogen/app/controllers/sites_controller.rb index 923bddb..352ffd5 100644 --- a/src/autogen/app/controllers/sites_controller.rb +++ b/src/autogen/app/controllers/sites_controller.rb @@ -66,7 +66,7 @@ class SitesController < ApplicationController # Only allow a list of trusted parameters through. def site_params - params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :server_ip, :server_port, :fileserver_ip, :fileserver_port,:fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country) + params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :api_ip, :api_port, :api_url, :fileserver_uri, :fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country) end diff --git a/src/autogen/app/models/site.rb b/src/autogen/app/models/site.rb index 0f35ca5..291e5ad 100644 --- a/src/autogen/app/models/site.rb +++ b/src/autogen/app/models/site.rb @@ -7,17 +7,19 @@ class Site field :nameserver, type: String field :network, type: String field :netmask, type: String - field :server_ip, type: String - field :server_port, type: String - field :fileserver_ip, type: String - field :fileserver_port, type: String + field :api_ip, type: String + field :api_port, type: String + field :api_url, type: String + field :fileserver_uri, type: String field :fileserver_basepath, type: String + field :fileserver_url, type: String + field :nfsserver_ip, type: String field :nfsserver_path, type: String field :country, type: String field :timezone, type: String - field :apiurl, type: String + field :description, type: String - field :cfenginehub, type: String + field :cfenginehub, type: String , default: '' has_many :sitereferences, class_name: "Host", inverse_of: :site end diff --git a/src/autogen/app/views/hosts/_form.html.erb b/src/autogen/app/views/hosts/_form.html.erb index 44c3a29..4fee4a5 100644 --- a/src/autogen/app/views/hosts/_form.html.erb +++ b/src/autogen/app/views/hosts/_form.html.erb @@ -238,3 +238,5 @@ + +<%= button_to "Edit Template", "/installtemplates/#{@host.installtemplate_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'}%> diff --git a/src/autogen/app/views/installtemplates/_form.html.erb b/src/autogen/app/views/installtemplates/_form.html.erb index fa35e88..bd04456 100644 --- a/src/autogen/app/views/installtemplates/_form.html.erb +++ b/src/autogen/app/views/installtemplates/_form.html.erb @@ -56,7 +56,7 @@ <%= form.text_field :kernel , { class: "input"} %> - +
<%= form.label :initrd, class: "label" %>
@@ -95,17 +95,24 @@
+
<%= form.label :lang, class: "label" %>
<%= form.text_field :lang , { class: "input"} %>
- +
- + <%= link_to "Return", "/installtemplates", class: "button is-success" %>
<% end %> - +
+
+ <%= button_to "Edit Boot", "/scripts/#{@installtemplate.boot_id}/edit", method: :get, class: "button is-small is-primary" , form: {target: '_blank'}%> + <%= button_to "Edit Install", "/scripts/#{@installtemplate.install_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'} %> + <%= button_to "Edit Post Install", "/scripts/#{@installtemplate.postinstall_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'} %> +
+
diff --git a/src/autogen/app/views/sites/_form.html.erb b/src/autogen/app/views/sites/_form.html.erb index 2980ec2..fb545ab 100644 --- a/src/autogen/app/views/sites/_form.html.erb +++ b/src/autogen/app/views/sites/_form.html.erb @@ -43,9 +43,9 @@
- <%= form.label :apiurl, class: "label" %> + <%= form.label :api_url, class: "label" %>
- <%= form.text_field :apiurl , { class: "input"} %> + <%= form.text_field :api_url , { class: "input"} %>
@@ -59,37 +59,37 @@
- +
- <%= form.text_field :server_ip , { class: "input"} %> + <%= form.text_field :api_ip , { class: "input"} %>
- +
- <%= form.text_field :server_port , { class: "input"} %> + <%= form.text_field :api_port , { class: "input"} %>
+
+ +
+ <%= form.text_field :api_url , { class: "input"} %> +
+
- +
- <%= form.text_field :fileserver_ip , { class: "input"} %> + <%= form.text_field :fileserver_uri , { class: "input"} %>
-
- -
- <%= form.text_field :fileserver_port , { class: "input"} %> -
-
- +
<%= form.text_field :fileserver_basepath , { class: "input"} %>
@@ -102,9 +102,8 @@ <%= form.text_field :cfenginehub , { class: "input"} %>
- <% if not @site.cfenginehub.empty? -%> - <%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %> - <% end -%> + <%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %> +
<%= form.label :country, class: "label" %> diff --git a/src/autogen/app/views/sites/_site.html.erb b/src/autogen/app/views/sites/_site.html.erb index 0fe43c8..baead43 100644 --- a/src/autogen/app/views/sites/_site.html.erb +++ b/src/autogen/app/views/sites/_site.html.erb @@ -31,7 +31,7 @@

Server: - <%= site.server_ip %>:<%= site.server_port %>: + <%= site.api_ip %>:<%= site.api_ip %>:

diff --git a/src/autogen/config/application.rb b/src/autogen/config/application.rb index 6fc192b..3570c7f 100644 --- a/src/autogen/config/application.rb +++ b/src/autogen/config/application.rb @@ -35,6 +35,6 @@ module Autogen # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") - config.hosts << "zeninstall.install.lan" + config.hosts << "zeninstall.zen6.info" end end diff --git a/src/autogen/config/mongoid.yml b/src/autogen/config/mongoid.yml index 3362a0c..2983aab 100644 --- a/src/autogen/config/mongoid.yml +++ b/src/autogen/config/mongoid.yml @@ -4,7 +4,7 @@ development: # Defines the default client. (required) default: # Mongoid can connect to a URI accepted by the driver: - uri: mongodb://railszen:railszen@mongo:27017/railszen + uri: mongodb://zeninstall:pTcwn5FSHWQaedVhxzLZ8g@mongo:27017/railszen # Otherwise define the parameters separately. # This defines the name of the default database that Mongoid can connect to. # (required). @@ -175,11 +175,11 @@ development: test: clients: default: - uri: mongodb://railszen:railszen@mongo:27017/railszen + uri: mongodb://zeninstall:pTcwn5FSHWQaedVhxzLZ8g @mongo:27017/railszen # database: autodeploy_test # hosts: # - localhost:27017 options: read: mode: :primary - max_pool_size: 1 \ No newline at end of file + max_pool_size: 1