Using 2014.7.5 with this state code:-
php5-stable-ppa:
pkgrepo.managed:
- ppa: ondrej/php5
- require:
- sls: linux.shared.ppa-support
- require_in:
- pkg: php5-fpm
- pkg: php5-cli
- pkg: php5-mysql
The state doesn't obviously fail, and the file is created in /etc/apt/sources.list.d but the key is not added, causing subsequent package installs to fail.
The debug log shows the problem:-
[INFO ] Running state [php5-stable-ppa] at time 16:39:53.495245
[INFO ] Executing state pkgrepo.managed for php5-stable-ppa
[INFO ] Executing command 'apt-add-repository -y ppa:ondrej/php5' in directory '/home/ubuntu'
[DEBUG ] stderr: gpg: keyring `/tmp/tmpy5cb__rf/secring.gpg' created
gpg: keyring `/tmp/tmpy5cb__rf/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpy5cb__rf/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 687, in addkey_func
func(**kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 370, in add_key
return apsk.add_ppa_signing_key()
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 261, in add_ppa_signing_key
tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 210, in _verify_fingerprint
got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _get_fingerprints
output = subprocess.check_output(cmd, universal_newlines=True)
File "/usr/lib/python3.4/subprocess.py", line 605, in check_output
output, unused_err = process.communicate(inputdata, timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 936, in communicate
stdout = _eintr_retry_call(self.stdout.read)
File "/usr/lib/python3.4/subprocess.py", line 487, in _eintr_retry_call
return func(*args)
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)
[INFO ] Executing command 'apt-get -q update' in directory '/home/ubuntu'
[INFO ] {'repo': 'ppa:ondrej/php5'}
[INFO ] Completed state [php5-stable-ppa] at time 16:39:59.648791
The PPA is at https://launchpad.net/~ondrej/+archive/ubuntu/php5 and the author's name is Ondřej Surý.
That looks like an issue with ppa.py, but could be handled by salt by changing the string encoding before sending it onto ppa.py.
@johnccfm, this may be fixed in 2015.5.0. Would you try to reproduce the issue with this version? Thanks.
I confirm this issue is still present in the 2015.5.0 version.
[INFO ] Executing state pkgrepo.managed for php5-stable-ppa
[INFO ] Executing command 'apt-add-repository -y ppa:ondrej/php5' in directory '/root'
[DEBUG ] stderr: gpg: keyring `/tmp/tmpskdqe1ix/secring.gpg' created
gpg: keyring `/tmp/tmpskdqe1ix/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpskdqe1ix/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 687, in addkey_func
func(**kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 370, in add_key
return apsk.add_ppa_signing_key()
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 261, in add_ppa_signing_key
tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 210, in _verify_fingerprint
got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _get_fingerprints
output = subprocess.check_output(cmd, universal_newlines=True)
File "/usr/lib/python3.4/subprocess.py", line 605, in check_output
output, unused_err = process.communicate(inputdata, timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 936, in communicate
stdout = _eintr_retry_call(self.stdout.read)
File "/usr/lib/python3.4/subprocess.py", line 487, in _eintr_retry_call
return func(*args)
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)
[INFO ] Executing command 'apt-get -q update' in directory '/root'
[INFO ] {'repo': 'ppa:ondrej/php5'}
[INFO ] Completed state [php5-stable-ppa] at time 08:39:53.060857
root@ip-10-99-0-124:~# salt-call grains.item saltversion
local:
----------
saltversion:
2015.5.0
Is this a regression? I've used this PPA before with the PHP Formula and not had problems.
I'm having the same issue. I am confused exactly where the failure is - I run the commands manually and it works fine.
@jfindlay I believe I have isolated it.
It appears that the environmental variable LC_ALL is set to C in the SaltStack environment.
When I set it in my test shell - I get the exact same error.
root@vagrant-ubuntu-trusty-64:/home/vagrant# export LC_ALL=C
root@vagrant-ubuntu-trusty-64:/home/vagrant# apt-add-repository -y ppa:ondrej/php5
gpg: keyring `/tmp/tmpwuy6x3qw/secring.gpg' created
gpg: keyring `/tmp/tmpwuy6x3qw/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpwuy6x3qw/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur?" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 687, in addkey_func
func(**kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 370, in add_key
return apsk.add_ppa_signing_key()
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 261, in add_ppa_signing_key
tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 210, in _verify_fingerprint
got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _get_fingerprints
output = subprocess.check_output(cmd, universal_newlines=True)
File "/usr/lib/python3.4/subprocess.py", line 605, in check_output
output, unused_err = process.communicate(inputdata, timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 936, in communicate
stdout = _eintr_retry_call(self.stdout.read)
File "/usr/lib/python3.4/subprocess.py", line 487, in _eintr_retry_call
return func(*args)
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)
I don't claim to full understand the option and it's interaction with the programs on the shell - but this StackOverflow answer provided some insight - http://unix.stackexchange.com/a/87763/44150.
Appears Salt has a few issues related to the LC_ALL environmental variable (from just doing a search).
@johnccfm here is the work around state I am using.
php5_ppa_cmd:
cmd.run:
- name: "apt-add-repository -y ppa:ondrej/php5"
- env:
- LC_ALL: 'en_US.UTF-8'
php5_ppa:
pkgrepo.managed:
- ppa: ondrej/php5
- require:
- cmd: php5_ppa_cmd
Run this before the PHP formula items in top.sls and it should work.
@s0undt3ch
Thanks for the workaround @RyPeck, this has been bugging me for over a year.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
I'd love a single complete working example on how to solve this. Still happens on Ubuntu 16, Salt 2018.3.3:
Command:
root@saltmaster: /srv/salt# salt 'webserver' state.apply php
Here is my php/init.sls :
php_ppa:
pkgrepo.managed:
- humanname: PHP Repo
- ppa: ondrej/php
- keyid: E5267A6C
- keyserver: keyserver.ubuntu.com
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C:
cmd.run:
- unless: 'apt-key list | grep Launchpad'
- order: first
php7.2:
pkg:
- installed
- require:
- pkgrepo: php_ppa
- pkgs:
- php7.2-common
- php7.2-dev
- php7.2-cli
- php7.2-mysql
- php7.2-curl
- php7.2-xmlrpc
- php7.2-gd
- php7.2-intl
- php7.2-mbstring
- php7.2-xml
- php7.2-zip
- php7.2-fpm
Here's the output on the master:
----------
ID: php_ppa
Function: pkgrepo.managed
Result: False
Comment: Failed to configure repo 'php_ppa': Unable to add PPA 'ondrej/php'. '[u'apt-add-repository', u'-y', u'ppa:ondrej/php']' exited with status 1: 'gpg: keyring `/tmp/tmpyir3avzn/secring.gpg' created
gpg: keyring `/tmp/tmpyir3avzn/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpyir3avzn/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)'
Started: 06:20:31.740267
Duration: 2271.678 ms
Changes:
----------
ID: php7.2
Function: pkg.installed
Result: False
Comment: One or more requisite failed: php.php_ppa
Started: 06:20:34.644341
Duration: 0.023 ms
Changes:
Summary for webserver
------------
Succeeded: 1 (changed=1)
Failed: 2
After it fails, if you run the state again, it seems the php_ppa already configured and its now going to install the rest of the packages - that is, php/init.sls ran 2 out of 3 stanzas and stopped with an error, but actually installed the repo correctly.
After much tinkering, this works with the latest PHP. Thanks @RyPeck
~~~
php72_ppa_cmd:
cmd.run:
- name: "apt-add-repository -y ppa:ondrej/php"
- env:
- LC_ALL: 'en_US.UTF-8'
php72_ppa:
pkgrepo.managed:
- ppa: ondrej/php
- require:
- cmd: php72_ppa_cmd
php7.2:
pkg:
- installed
- require:
- php72_ppa
- pkgs:
- php7.2-common
- php7.2-dev
- php7.2-cli
- php7.2-mysql
- php7.2-curl
- php7.2-xmlrpc
- php7.2-gd
- php7.2-intl
- php7.2-mbstring
- php7.2-xml
- php7.2-zip
- php7.2-fpm
~~~
Most helpful comment
@johnccfm here is the work around state I am using.
Run this before the PHP formula items in top.sls and it should work.