Java debconf

877 views
Skip to first unread message

Valentin Bud

unread,
May 20, 2013, 7:36:33 AM5/20/13
to Salt Stack User
Hello Community,

I am trying to preseed the answer to sun-java6-* packages using
debconf.set.

On a machine I already have Java installed and deconf-get-selections
reports the following:

$ debconf-get-selections|grep java
sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre sun-java6-jre/stopthread boolean true
sun-java6-jre sun-java6-jre/jcepolicy note
sun-java6-bin shared/error-sun-dlj-v1-1 error
sun-java6-jre shared/error-sun-dlj-v1-1 error
sun-java6-bin shared/present-sun-dlj-v1-1 note
sun-java6-jre shared/present-sun-dlj-v1-1 note

The Salt state I have created for this is the following:

include:
- debconf-utils

sun_java6_bin:
pkg.installed:
- name: sun-java6-bin
- require:
- debconf: sun_java6_bin_debconf

sun_java6_bin_debconf:
debconf.set:
- name: sun-java6-bin
- data:
'shared/accepted-sun-dlj-v1-1':
'type': 'boolean'
'value': 'true'

sun_java6_jre_debconf:
debconf.set:
- name: sun-java6-jre
- data:
'shared/accepted-sun-dlj-v1-1':
'type': 'boolean'
'value': 'true'

salt 'java-machine.*' state.highstate reports the following:

java-machine.domain.tld:
----------
State: - debconf
Name: sun-java6-bin
Function: set
Result: False
Comment: An exception occurred in this state: Traceback (most
recent call last):
File "/usr/lib/python2.6/dist-packages/salt/state.py", line 1210, in
call
ret = self.states[cdata['full']](*cdata['args'])
File "/usr/lib/python2.6/dist-packages/salt/states/debconfmod.py",
line 122, in set
for (key, args) in data.iteritems():
AttributeError: 'NoneType' object has no attribute 'iteritems'

Changes:
----------
State: - debconf
Name: sun-java6-jre
Function: set
Result: False
Comment: An exception occurred in this state: Traceback (most
recent call last):
File "/usr/lib/python2.6/dist-packages/salt/state.py", line 1210, in
call
ret = self.states[cdata['full']](*cdata['args'])
File "/usr/lib/python2.6/dist-packages/salt/states/debconfmod.py",
line 122, in set
for (key, args) in data.iteritems():
AttributeError: 'NoneType' object has no attribute 'iteritems'

Changes:
----------
State: - pkg
Name: sun-java6-bin
Function: installed
Result: False
Comment: One or more requisite failed
Changes:

The log on the minion is set to debug and I see the following (relevant)
information in `/var/log/salt/minion`:

2013-05-20 14:22:06,012 [salt.state ][INFO ] Executing state
debconf.set for sun-java6-bin
2013-05-20 14:22:06,012 [salt.loaded.int.module.cmdmod][INFO ]
Executing command 'debconf-get-selections' in directory '/root'
2013-05-20 14:22:06,194 [salt.loaded.int.module.cmdmod][DEBUG ]
stdout: # Time zone:
# Choices: Adelaide, Brisbane, Broken Hill, Canberra, Currie, Darwin,
# Eucla, Hobart, Lindeman, Lord Howe, Melbourne, Perth, Sydney,
# Yancowinna
tzdata tzdata/Zones/Australia select
#

[... a lot of information about debconf ...]

2013-05-20 14:22:06,381 [salt.state ][ERROR ] No changes made
for sun-java6-jre
2013-05-20 14:22:06,382 [salt.state ][INFO ] Executing state
file.managed for /etc/apt/sources.list

Am I using debconf.set correctly? Thank you for your help.

Cheers and Goodwill,
--
Valentin Bud
http://databus.pro/ | vale...@databus.pro

Colton Myers

unread,
May 28, 2013, 12:20:49 PM5/28/13
to salt-...@googlegroups.com
Did you ever find a way to get this to work?  I would be interested in your results if so, I had trouble installing Sun Java for a Minecraft server using Salt because of debconf.

If it's still an issue, I'll try to find time to look into it.

--
Colton Myers



--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Nick Davis

unread,
May 28, 2013, 12:36:49 PM5/28/13
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Colton,
I am not the OP, but I did want to say that I've been using
"debconf.set_file" for quite a while with no issues. Perhaps you would
want to give that a try instead of debconf.set? You could put a whole
mix of debconf commands in the same file.

Here is how I use it:

debconf-pkgs:
pkg.installed:
- pkgs:
- debconf
- debconf-utils

ldap-debconf-settings:
debconf.set_file:
- source: salt://path/to/ldap-debconf-preseed?env=ldap-env
- require:
- pkg: debconf-pkgs

And then the ldap-debconf-preseed file has content like the following
with each debconf entry on a separate line separated by at least one
space (note, I edited it a bit, so other LDAP users will want to add
some additional instructions):

ldap-auth-config ldap-auth-config/binddn string dc=example,dc=com
ldap-auth-config ldap-auth-config/dblogin boolean false
ldap-auth-config ldap-auth-config/dbrootlogin boolean false
ldap-auth-config ldap-auth-config/ldapns/base-dn string
dc=example,dc=com
ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3
ldap-auth-config ldap-auth-config/move-to-debconf boolean true
ldap-auth-config ldap-auth-config/override boolean true
ldap-auth-config ldap-auth-config/pam_password select crypt
libnss-ldap libnss-ldap/confperm boolean false
libnss-ldap libnss-ldap/dblogin boolean false
libnss-ldap libnss-ldap/dbrootlogin boolean false
libnss-ldap libnss-ldap/nsswitch note
libnss-ldap libnss-ldap/override boolean true


Cheers,
Nick
> http://databus.pro/ | vale...@databus.pro <mailto:vale...@databus.pro>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to salt-users+...@googlegroups.com
> <mailto:salt-users%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to salt-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlGk3SEACgkQYoNGId/piAvdewCgiNZ4Q/FaVgwwU+MwYrMrSzAP
SlEAnRMM6EkuAZW+5SqHdQjl/jS9nVyR
=Xrj1
-----END PGP SIGNATURE-----

Valentin Bud

unread,
May 28, 2013, 1:52:41 PM5/28/13
to salt-...@googlegroups.com
Hi Colton,

I have found another way of doing it using salt.

~/code/salt-states/java/init.sls

include:
- debconf-utils
- apt

sun_java_bin:
pkg.installed:
- name: sun-java6-bin
- require:
- cmd: sun_java_bin_debconf
- file: default_sources_list

sun_java_jre:
pkg.installed:
- name: sun-java6-jre
- require:
- cmd: sun_java_jre_debconf
- file: default_sources_list

sun_java_bin_debconf:
cmd.run:
- name: echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean
true" | debconf-set-selections
- unless: debconf-get-selections | grep sun-java6-bin
- require:
- pkg: debconf-utils

sun_java_jre_debconf:
cmd.run:
- name: echo "sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean
true" | debconf-set-selections
- unless: debconf-get-selections | grep sun-java6-jre
- require:
- pkg: debconf-utils

I will try to use debconf.set_file, as Nick suggests, and come back with
results. I have a hunch that Nick's version is better in the long run.

Cheers,
Valentin

Colton Myers

unread,
May 29, 2013, 3:30:36 PM5/29/13
to salt-...@googlegroups.com
Awesome, glad you found a workaround.  Keep us posted, I'd also be interested to see if the debconf.set_file works.  =)

--
Colton Myers

Valentin Bud

unread,
May 30, 2013, 4:12:26 PM5/30/13
to salt-...@googlegroups.com
Hi Colton,

It doesn't work. I receive "Unable to set deconf selections from file
error".

java6/init.sls

include:
- debconf-utils

java6_debconf_file:
debconf.set_file:
- source: salt://java6/debconf.file
- require:
- pkg: debconf_utils

java6_bin:
pkg.installed:
- name: {{ pillar['java6_bin'] }}
- require:
- debconf: java6_debconf_file

java6_jre:
pkg.installed:
- name: {{ pillar['java6_jre'] }}
- require:
- debconf: java6_debconf_file

The error I receive running state.highstate from the master:

debconf-test
----------
State: - debconf
Name: java6_debconf_file
Function: set_file
Result: False
Comment: Unable to set debconf selections from file.
Changes:
----------
State: - pkg
Name: sun-java6-bin
Function: installed
Result: False
Comment: One or more requisite failed
Changes:
----------
State: - pkg
Name: sun-java6-jre
Function: installed
Result: False
Comment: One or more requisite failed
Changes:

I will run salt-minion with debug log to see if I can find out more.

Cheers and Goodwill,

Valentin Bud

unread,
May 30, 2013, 5:24:13 PM5/30/13
to salt-...@googlegroups.com
It does work :).

diff --git a/java6/init.sls b/java6/init.sls
index 9441152..89ecf72 100644
--- a/java6/init.sls
+++ b/java6/init.sls
@@ -3,7 +3,7 @@ include:

java6_debconf_file:
debconf.set_file:
- - source: salt://java6/debconf.file
+ - source: salt://java6/debconf.file?env={{ grains['env'] }}
- require:
- pkg: debconf_utils

Thanks for Salt :-).
Cheers and Goodwill,

Colton Myers

unread,
May 30, 2013, 5:31:08 PM5/30/13
to salt-...@googlegroups.com
Awesome!  Glad we figured it out.  Now I need to add it to my server when I get the chance....  =)

--
Colton Myers
Reply all
Reply to author
Forward
0 new messages