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"} %> - +
Server: - <%= site.server_ip %>:<%= site.server_port %>: + <%= site.api_ip %>:<%= site.api_ip %>: