Works fine when executed from terminal (as root user):
add-apt-repository ppa:ondrej/php -y
apt-get update
apt-get install -y git-core acl curl nginx php7.1-fpm php7.1-curl php7.1-mysql php7.1-soap php7.1-bcmath php7.1-mbstring php7.1-mongodb unzip php7.1-apcu php7.1-dev php-pear php7.1-pgsql libaio1 php7.1-gd php-apc php7.1-intl php7.1-sqlite libfontconfig1 libxrender1
Logging from the script (written in golang, run by juju with root user):
2017-03-23 18:23:22 INFO upgrade-charm + /var/lib/juju/agents/unit-cloud-3/charm/bin/runhook upgrade-charm
2017-03-23 18:23:22 INFO juju-log running hook upgrade-charm {
2017-03-23 18:23:22 INFO upgrade-charm 2017/03/23 19:23:22 add-apt-repository [ppa:ondrej/php -y]
2017-03-23 18:23:22 INFO upgrade-charm 2017/03/23 19:23:22 apt-get [update]
2017-03-23 18:23:27 INFO upgrade-charm 2017/03/23 19:23:27 apt-get [install -y git-core acl curl nginx php7.1-fpm php7.1-curl php7.1-mysql php7.1-soap php7.1-bcmath php7.1-mbstring php7.1-mongodb unzip php7.1-apcu php7.1-dev php-pear php7.1-pgsql libaio1 php7.1-gd php-apc php7.1-intl php7.1-sqlite libfontconfig1 libxrender1]
2017-03-23 18:23:27 INFO upgrade-charm 2017/03/23 19:23:27 Error: [exit status 100]
... (more stuff)
2017-03-23 18:23:27 INFO juju-log } upgrade-charm
2017-03-23 18:23:27 INFO upgrade-charm runhook: exit status 100
2017-03-23 18:23:27 ERROR juju.worker.uniter.operation runhook.go:107 hook "upgrade-charm" failed: exit status 1
Then when I run "apt-get update":
...
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C