Pergunta

I am currently using Vagrant to install a glassfish server via chef_solo cookbook. Everything installs correctly and I can access the server, but it requires that I enable secure_admin to access the server remotely from my host machine.

The problem lies in that I cannot seem to find, or understand the JSON syntax for Vagrant to properly modify the attribute for secure_admin to enable.

I am using this cookbook: https://github.com/realityforge/chef-glassfish

In the instructions it explains to modify such attributes to enter code such as this:

# Create a basic domain that logs to a central graylog server
glassfish_domain "my_domain" do
  port 80
  admin_port 8103
  extra_libraries ['https://github.com/downloads/realityforge/gelf4j/gelf4j-0.9-all.jar']
  logging_properties {
    "handlers" => "java.util.logging.ConsoleHandler, gelf4j.logging.GelfHandler",
    ".level" => "INFO",
    "java.util.logging.ConsoleHandler.level" => "INFO",
    "gelf4j.logging.GelfHandler.level" => "ALL",
    "gelf4j.logging.GelfHandler.host" => 'graylog.example.org',
    "gelf4j.logging.GelfHandler.defaultFields" => '{"environment": "' + node.chef_environment + '", "facility": "MyDomain"}'
  }
end

However, if I wish to modify features such as the port or domain name, I have to edit those attributes with this syntax (Whats in my vagrantfile already):

chef.json = {


    "glassfish" => {
         "base_dir" => "/usr/local/glassfish",
         "domains_dir" => "/usr/local/glassfish/glassfish/domains",
         "domains" => {
            "domain1" => {
               "config" => {
             "domain_name" => "domain1",
             "admin_port" => 4848,
             "username" => "root",
             "password" => "admin",
                }
            }
        }
    }

}

This code makes sense to me as I see within the recipe "attribute_driven_domain" in this cookbook, that the open statements are described as such. Meaning to edit the minimum memory of the domain, I would have type:

"glassfish" => {
   "domains" => {
      "domain1" => {
         "config" => {
            "min_memory" => 512
         }
      }
   }
}

Which this ^ , corresponds to:

['glassfish']
['domains']
['config']
['min_memory']

....Found in this section of the recipe:

gf_sort(node['glassfish']['domains']).each_pair do |domain_key, definition|
  domain_key = domain_key.to_s

  Chef::Log.info "Defining GlassFish Domain #{domain_key}"

  admin_port = definition['config']['admin_port']
  username = definition['config']['username']
  secure = definition['config']['secure']
  password_file = username ? "#{node['glassfish']['domains_dir']}/#{domain_key}_admin_passwd" : nil
  system_username = definition['config']['system_user']
  system_group = definition['config']['system_group']

  if (definition['config']['port'] && definition['config']['port'] < 1024) || (admin_port && admin_port < 1024)
    include_recipe 'authbind'
  end

glassfish_domain domain_key do
    min_memory definition['config']['min_memory'] if definition['config']['min_memory']
    max_memory definition['config']['max_memory'] if definition['config']['max_memory']
    max_perm_size definition['config']['max_perm_size'] if definition['config']['max_perm_size']
    max_stack_size definition['config']['max_stack_size'] if definition['config']['max_stack_size']
    port definition['config']['port'] if definition['config']['port']

However, at the part that defines the secure admin, I can't see a distinct place that would indicate where it is supposed to be placed in the chef.json block. Found in this section:

glassfish_secure_admin "#{domain_key}: secure_admin" do
    domain_name domain_key
    admin_port admin_port if admin_port
    username username if username
    password_file password_file if password_file
    secure secure if secure
    system_user system_username if system_username
    system_group system_group if system_group
    action ('true' == definition['config']['remote_access'].to_s) ? :enable : :disable
  end

I can't seem to figure out where the secure_admin attribute is suppose to placed in the chef.json block within my vagrantfile. I've tried placing it different spots, such as under the glassfish level, under the domains level, under the config.

I really don't know what I am exactly suppose to put, or where.

I have been using variants of this:

"secure_admin" => {
  "domain_name" => "domain1"
  "action" => :enable
}

or like this if it was under domain1 but above config:

"secure_admin" => {
  "action" => :enable
}

Most of the time it doesn't give any feedback of change or error, sometimes if its put in certain spots it fails because it tries to read it as a separate domain, but other than that not much.

Is the syntax that I'm currently using to modify attributes incorrect? I'm pretty fresh with this stuff, so I don't really know. Sorry for the terribly long post.

Foi útil?

Solução

It looks like to enable remote access you would set the node attribute for domain['config']['remote_access'] to true. This is just a guess based on the ternary operator. So in your original example:

"glassfish" => {
         "base_dir" => "/usr/local/glassfish",
         "domains_dir" => "/usr/local/glassfish/glassfish/domains",
         "domains" => {
            "domain1" => {
               "config" => {
             "domain_name" => "domain1",
             "admin_port" => 4848,
             "username" => "root",
             "password" => "admin",
             "remote_access" => true
                }
            }
        }
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top