Use `apt-get` in scripts consistently
Created by: DEiselt
Starting from a discussion in PR #524 (Thread), i did some investigation around this topic.
Summary for "apt vs apt-get":
apt
is designed for interactive use and the "stable cli" is in reference to the possibility of changes breaking backwards compatibility if the "user friendly" aspect weighs stronger.apt-get
is preferred for scripts to be safer in regards to future changes.
Source: apt(8) manpage
The apt(8) commandline is designed as an end-user tool and it may change behavior between versions. While it tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt- cache(8) as well. apt(8) just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you should prefer using these commands (potentially with some additional options enabled) in your scripts as they keep backward compatibility as much as possible.
This issue has the goal to follow this approach and improve the consistency in our code. Currently, both (apt
and apt-get
) are use in different places.
Usage of apt
:
./terraform/files/bin/deploy_harbor.sh:32:sudo apt install -y pwgen apache2-utils
./terraform/files/bin/bootstrap.sh:33:sudo apt install --no-install-recommends --no-install-suggests -y binutils jq
./terraform/files/bin/prepare_openstack.sh:6:sudo apt install --no-install-recommends --no-install-suggests -y python3-openstackclient python3-octaviaclient
./terraform/mgmtcluster.tf:115: - apt -y install --no-install-recommends --no-install-suggests docker.io yamllint qemu-utils git