Installing with apt succeeds but packages are not installed - python-3.x

I'm using Ansible to install Apt packages on a lxd Ubuntu20.04 container running an Ubuntu 20.04 host.
The container is created successfully and commands execute in the container as expected.
But using apt through Ansible does not. Ansible shows successful task run but when I enter the container the packages have not been installed.
I've recently upgraded the version of Ansible to the latest and have been following along from Ansible docs. I've tried bot the apt and ansible.builtin.apt formats. The results remain the same Ansible fails silently.
I was expecting to see a response from php -v and nginx -t when I enter the container. Expecting configs at /etc/nginx and /etc/php
Tasks
tasks:
- name: apt-get update
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600
- name: Install Nginx PHP
delegate_to: "{{ lxd_container_name }}"
ansible.builtin.apt:
state: latest
pkg:
- nginx
- python3-pymysql
- php8.1
- php8.1-mysql
- name: Install PHP Extensions
delegate_to: "{{ lxd_container_name }}"
apt: name={{ item }} update_cache=yes state=latest
loop: "{{ php_modules }}"
Ansible version: 2.11.5
Python version: 3.8
Output of running this playbook:
PLAY [localhost] **************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************
ok: [localhost]
TASK [apt-get update] *********************************************************************************************************************************************
ok: [localhost]
TASK [Install Nginx PHP] ******************************************************************************************************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 20.04 on host localhost should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior
Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible-
core/2.11/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
ok: [localhost -> template]
TASK [Install PHP Extensions] *************************************************************************************************************************************
ok: [localhost -> template] => (item=php-curl)
ok: [localhost -> template] => (item=php-gd)
ok: [localhost -> template] => (item=php-mbstring)
ok: [localhost -> template] => (item=php-xml)
ok: [localhost -> template] => (item=php-xmlrpc)
ok: [localhost -> template] => (item=php-soap)
ok: [localhost -> template] => (item=php-intl)
ok: [localhost -> template] => (item=php-zip)
Result in the container shows that the packages where not installed after several attempts.
root#template:~# nginx
bash: nginx: command not found
root#template:~# php
bash: php: command not found
root#template:~# cd /etc/php
bash: cd: /etc/php: No such file or directory
root#template:~# apt install php8.1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils bzip2 file libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1
libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.5-0 libldap-common liblua5.3-0 libmagic-mgc libmagic1 libnghttp2-14 libperl5.34 libpsl5 librtmp1
libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 mailcap mime-support perl perl-modules-5.34 php-common php8.1-cli php8.1-common php8.1-opcache
php8.1-readline psmisc publicsuffix ssl-cert xz-utils
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser ufw bzip2-doc php-pear gdbm-l10n libsasl2-modules-gssapi-mit
| libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql perl-doc libterm-readline-gnu-perl
| libterm-readline-perl-perl make libtap-harness-archive-perl
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils bzip2 file libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1
libcurl4 libgdbm-compat4 libgdbm6 libjansson4 libldap-2.5-0 libldap-common liblua5.3-0 libmagic-mgc libmagic1 libnghttp2-14 libperl5.34 libpsl5 librtmp1
libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 mailcap mime-support perl perl-modules-5.34 php-common php8.1 php8.1-cli php8.1-common php8.1-opcache
php8.1-readline psmisc publicsuffix ssl-cert xz-utils
0 upgraded, 43 newly installed, 0 to remove and 0 not upgraded.
Need to get 17.4 MB of archives.
After this operation, 90.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
root#template:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
fontconfig-config fonts-dejavu-core libbrotli1 libdeflate0 libfontconfig1 libfreetype6 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmaxminddb0
libnginx-mod-http-geoip2 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2
libpng16-16 libtiff5 libwebp7 libxpm4 libxslt1.1 nginx-common nginx-core
Suggested packages:
libgd-tools mmdb-bin fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
fontconfig-config fonts-dejavu-core libbrotli1 libdeflate0 libfontconfig1 libfreetype6 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmaxminddb0
libnginx-mod-http-geoip2 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2
libpng16-16 libtiff5 libwebp7 libxpm4 libxslt1.1 nginx nginx-common nginx-core
0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.
Need to get 3773 kB of archives.
After this operation, 11.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] n

Related

Let Ansible chocolatey check the Software-Version before installation

I try to write a small script in ansible chocolatey to proof if the last version of 7zip is installed and if not, to install it and this is the code.
I try it from an Ubuntu 20 server and my target is in Win 11
---
- name: Check and update 7zip
hosts: win
become_method: runas
tasks:
- name: Install Chocolatey
win_chocolatey:
name: chocolatey
state: present
- name: Check for 7zip
win_chocolatey:
name: 7zip
state: present
check_install: yes
- name: Update 7zip
win_chocolatey:
name: 7zip
state: latest
when: not 7zip.check_install
and get allways this error
`PLAY [Check and update 7zip] *******************************************************************************************
TASK [Gathering Facts] *************************************************************************************************
ok: [192.168.80.146]
TASK [Install Chocolatey] **********************************************************************************************
ok: [192.168.80.146]
TASK [Check for 7zip] **************************************************************************************************
fatal: [192.168.80.146]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (win_chocolatey) module: check_install. Supported parameters include: skip_scripts, override_args, bootstrap_script, remove_dependencies, force, allow_multiple, proxy_username, allow_prerelease, state, install_args, pinned, timeout, source_username, source, ignore_checksums, proxy_password, bootstrap_tls_version, choco_args, package_params, ignore_dependencies, architecture, proxy_url, name, allow_empty_checksums, validate_certs, source_password, install_ps1, bootstrap_ps1, execution_timeout, tls_version, tls_versions, bootstrap_tls_versions, licensed_args, params"}
PLAY RECAP *************************************************************************************************************
192.168.80.146 : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0`
can someone maybe help me?
I tryed 1000s staff and googled and and and with no result
I tryed staff like this:
when: not 7zip.state | default('absent') also no result

DVC | Permission denied ERROR: failed to reproduce stage: failed to run: .py, exited with 126

Goal: run .py files via. dvc.yaml.
There are stages before it, in dvc.yaml, that don't produce the error.
dvc exp run:
(venv) me#ubuntu-pcs:~/PycharmProjects/project$ dvc exp run
Stage 'inference' didn't change, skipping
Running stage 'load_data':
> load_data.py
/bin/bash: line 1: load_data.py: Permission denied
ERROR: failed to reproduce 'load_data': failed to run: load_data.py, exited with 126
dvc repro:
(venv) me#ubuntu-pcs:~/PycharmProjects/project$ dvc repro
Stage 'predict' didn't change, skipping
Stage 'evaluate' didn't change, skipping
Stage 'inference' didn't change, skipping
Running stage 'load_data':
> load_data.py
/bin/bash: line 1: load_data.py: Permission denied
ERROR: failed to reproduce 'load_data': failed to run: pdl1_lung_model/load_data.py, exited with 126
dvc doctor:
DVC version: 2.10.2 (pip)
---------------------------------
Platform: Python 3.9.12 on Linux-5.15.0-46-generic-x86_64-with-glibc2.35
Supports:
webhdfs (fsspec = 2022.5.0),
http (aiohttp = 3.8.1, aiohttp-retry = 2.5.2),
https (aiohttp = 3.8.1, aiohttp-retry = 2.5.2),
s3 (s3fs = 2022.5.0, boto3 = 1.21.21)
Cache types: hardlink, symlink
Cache directory: ext4 on /dev/nvme0n1p5
Caches: local
Remotes: s3
Workspace directory: ext4 on /dev/nvme0n1p5
Repo: dvc, git
dvc exp run -v:
output.txt
dvc exp run -vv:
output2.txt
Solution 1
.py files weren't running as scripts.
They need to be; if you want to run one .py file per stage in dvc.yaml.
To do so, you want to append Boiler-plate code, at the bottom of each .py file.
if __name__ == "__main__":
# invoke primary function() in .py file, w/ params
Solution 2
chmod 777 ....py
Soution 3
I forgot the python in cmd:
load_data:
cmd: python pdl1_lung_model/load_data.py

How to fix Anaconda ProxyError in Ubuntu 20.04?

I have instilled a Anaconda with the infromation:
:~$ conda info
conda info --all
active environment : None
user config file : /home/qic220/.condarc
populated config files : /home/qic220/.condarc
conda version : 4.8.3
conda-build version : 3.18.11
python version : 3.8.3.final.0
virtual packages : __cuda=11.1
__glibc=2.31
base environment : /home/qic220/anaconda3 (writable)
channel URLs : http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
package cache : /home/qic220/anaconda3/pkgs
/home/qic220/.conda/pkgs
envs directories : /home/qic220/anaconda3/envs
/home/qic220/.conda/envs
platform : linux-64
user-agent : conda/4.8.3 requests/2.24.0 CPython/3.8.3 Linux/5.4.0-42-generic ubuntu/20.04.1 glibc/2.31
UID:GID : 1000:1000
netrc file : None
offline mode : False
# conda environments:
#
base * /home/qic220/anaconda3
sys.version: 3.8.3 (default, Jul 2 2020, 16:21:59)
...
sys.prefix: /home/qic220/anaconda3
sys.executable: /home/qic220/anaconda3/bin/python
conda location: /home/qic220/anaconda3/lib/python3.8/site-packages/conda
conda-build: /home/qic220/anaconda3/bin/conda-build
conda-convert: /home/qic220/anaconda3/bin/conda-convert
conda-debug: /home/qic220/anaconda3/bin/conda-debug
conda-develop: /home/qic220/anaconda3/bin/conda-develop
conda-env: /home/qic220/anaconda3/bin/conda-env
conda-index: /home/qic220/anaconda3/bin/conda-index
conda-inspect: /home/qic220/anaconda3/bin/conda-inspect
conda-metapackage: /home/qic220/anaconda3/bin/conda-metapackage
conda-render: /home/qic220/anaconda3/bin/conda-render
conda-server: /home/qic220/anaconda3/bin/conda-server
conda-skeleton: /home/qic220/anaconda3/bin/conda-skeleton
conda-verify: /home/qic220/anaconda3/bin/conda-verify
user site dirs:
ALL_PROXY: <set>
CIO_TEST: <not set>
CONDA_ROOT: /home/qic220/anaconda3
C_INCLUDE_PATH: /usr/local/cuda/include:
DEFAULTS_PATH: /usr/share/gconf/ubuntu.default.path
HTTPS_PROXY: <set>
HTTP_PROXY: <set>
LD_LIBRARY_PATH: /opt/ovito-basic-3.3.1-x86_64/lib:/usr/local/cuda/lib64::/opt/vmd-1.9.4a48/lib
MANDATORY_PATH: /usr/share/gconf/ubuntu.mandatory.path
NO_PROXY: <set>
PATH: /home/qic220/anaconda3/bin:/opt/ovito-basic-3.3.1-x86_64/bin:/home/qic220/lammps-stable_29Oct2020/src:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/software/anaconda3/bin:/opt/vmd-1.9.4a48/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
WINDOWPATH: 2
But when I tried to install a package, it failed and a ProxyError arised:
$ conda install -c conda-forge hoomd
Collecting package metadata (current_repodata.json): failed
ProxyError: Conda cannot proceed due to an error in your proxy configuration.
Check for typos and other configuration errors in any '.netrc' file in your home directory,
any environment variables ending in '_PROXY', and any other system-wide proxy
configuration settings.
Actually, even I just use conda update conda, there still is ProxyError.
I have check env | grep proxy, nothing shown on my screen.
And I also modified .condsrc as:
proxy_servers:
http: http://username:password#corp.com:8080
https: https://username:password#corp.com:8080
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
After source ~/.condarc, it still not work. Is anyone have idea to fixed my problem?

port isolation with bazel and linux

Trying to test out port isolation with bazel and linux and it fails.
My env is as following (started on aws):
$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ uname -mrs
Linux 3.16.0-4-amd64 x86_64
Bazel version
$ bazel version
Build label: 0.5.1
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 6 10:34:11 2017 (1496745251)
Build timestamp: 1496745251
Build timestamp as int: 1496745251
The repo: https://github.com/ittaiz/bazel-port-isolation
Running the test:
$ bazel test //...
____Loading package:
____Loading package: #bazel_tools//tools/cpp
____Loading package: #local_config_xcode//
____Loading package: #local_jdk//
____Loading package: #local_config_cc//
____Loading complete. Analyzing...
____Loading package: tools/defaults
____Loading package: #bazel_tools//tools/test
____Loading package: #junit_junit//jar
____Found 2 test targets...
____Building...
____[0 / 12] Expanding template SocketIsolation2Test
____[10 / 12] Building SocketIsolationTest.jar (1 source file)
FAIL: //:SocketIsolation2Test (see /home/builduser/.cache/bazel/_bazel_builduser/a589c0f8758972ab3aadcf172c468873/execroot/bazel-port-isolation/bazel-out/local-fastbuild/testlogs/SocketIsolation2Test/test.log)
PASS: //:SocketIsolationTest
____Elapsed time: 11.152s, Critical Path: 7.03s
//:SocketIsolationTest PASSED in 5.3s
//:SocketIsolation2Test FAILED in 0.3s
/home/builduser/.cache/bazel/_bazel_builduser/a589c0f8758972ab3aadcf172c468873/execroot/bazel-port-isolation/bazel-out/local-fastbuild/testlogs/SocketIsolation2Test/test.log
(As you can see - no sandbox failure or warnings)
The tet log show "Address already in use" - which means that there were no port isolation.
Why is it not working?
Found out why...
From here: https://bazel.build/versions/master/docs/bazel-user-manual.html#sandboxing
On some platforms such as Google Container Engine cluster nodes or
Debian, user namespaces are deactivated by default due to security
concerns. This can be checked by looking at the file
/proc/sys/kernel/unprivileged_userns_clone: if it exists and contains
a 0, then user namespaces can be activated with sudo sysctl
kernel.unprivileged_userns_clone=1.
The /proc/sys/kernel/unprivileged_userns_clone existed and had 0 in it.. . so changing it according to the insturction solved it.

Centos cgconfig fails to start

I need docker installed on one of my servers, and whenever I try to start the docker service, it fails because of cgconfig. Cgconfig throws the following error:
Starting cgconfig service: Error: cannot mount cpu to /cgroup/cpu: No such file or directory
/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Failed to parse /etc/cgconfig.conf or /etc/cgconfig.d [FAILED]
I'm running CentOS 6.5 Final with the following /etc/cgconfig.conf file:
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpuacct;
memory = /cgroup/memory;
devices = /cgroup/devices;
freezer = /cgroup/freezer;
net_cls = /cgroup/net_cls;
blkio = /cgroup/blkio;
}
I appreciate any responses
To use cgroups on newer versions of CentOS you need to install libcgroup as well as libcgroup-tools:
$ sudo yum install libcgroup
$ sudo yum install libcgroup-tools
To create group use cgcreate, e.g.:
$ sudo cgcreate -g memory,cpu,blkio,cpuset:userlimited
To verify that /etc/cgconfig.conf is correct use cgconfigparser
$ cgconfigparser -l /etc/cgconfig.conf
For details check: https://wiki.archlinux.org/index.php/cgroups
Note: In CentOS 6 and earlier versions one only needed to install libcgroup
This error may be due to kernel you are using is booted with cgroup_disable=memory and/or /etc/cgconfig.conf
contains "memory=/cgroup/memory", in your case you may solve this by commenting out "memory = /cgroup/memory" from cgconfig.conf.
You can also refer 1 or 2 for more information.

Resources