Install microk8s via snap using Ansible, on WSL 2 - linux

I'm trying to install microk8s, using Ansible.
I get the error : "No snap matching 'microk8s' available"
I'm using WSL 2 (Ubuntu 20.04), and snap version 2.44.3+20.04.
My configuration:
- name: Install microk8s
snap:
name:
- microk8s
classic: yes
become: true
Does anyone know how to fix this?

On the WSL terminal, what happens if you type: snap version.
It seems that snap is broken on WSL2 and using Ubuntu 20.04.
You could try to:
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
It could also be a network/firewall issue. What happens if you try to install other packages.

Related

Jenkins installation on Ubuntu using Vagrant - NO HTTP access

I've been trying to install Jenkins on ubuntu using Vagrant. Even though I am not getting any errors along the way I am not able to open http://localhost:8080
Here's my steps:
Install Vagrant and Virtual Box on MAC
Create a folder for the vagrant
vagrant init bento/ubuntu-16.04
nano Vagrantfile - delete the hasztag from the port forwarding to 8080
Vagrant up
Vagrant ssh
Install git:
Sudo apt-get install git
Git --version
Installing Java:
sudo apt update
Sudo apt-get upgrade
sudo apt install default-jdk
sudo apt install default-jre
Install Jenkins:
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get install -y jenkins --allow-unauthenticated
To check the password: vi /var/log/jenkins/jenkins.log
To start Jenkins: systemctl start jenkins
systemctl status jenkins
When I start the jenkins server I can do telnet 127.0.0.1 8080 but when I turn it off it doesn't work. Any idea why I cannot access GUI using the browser?
Try in ubuntu to do "curl http://localhost:8080" , if response is not some error code page, like 4xx/5xx, check firewall and allow traffic on port 8080. Therefore try to access Jenkins from Host Machine.
Make sure you don't have a service running on port 8080 on your guest machine.

Installing docker-compose on Amazon EC2 Linux 2. 9kb docker-compose file

First of all, let me state I'm not the most virtuous of Linux users, so bear with me...
Below is a brief run-down of all the steps I took. Ultimately the question/issue is is that it seems impossible for me to get a proper docker-compose installation downloaded.
Followed instructions to install docker https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Tried 4 variations of the above command to try to install docker-compose. As shown in the URLs below.
https://www.codegrepper.com/code-examples/php/how+to+install+docker+compose+in+ec2
https://portal.cloud303.io/forum/aws-1/question/i-want-to-install-docker-compose-on-an-amazon-linux-2-ec2-instance-9
https://acloudxpert.com/how-to-install-docker-compose-on-amazon
https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9
When typing "docker-compose", "sudo docker-compose" etc. All it will say is
"Line 1: Not: command not found".
It seems to be the issue that the docker-compose file is only 9kb in size. Because this is what I get back every time I use the above mentioned docker-compose install sequences.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9 100 9 0 0 58 0 --:--:-- --:--:-- --:--:-- 58
This issue is sort of addressed here:
https://github.com/docker/compose/issues/6268
Where it is said that the OS is not supported or that we're running a 32bit instance, but of which seem to be strange because all the above tutorials are specifically for AWS EC2 Linux 2.
fwiw 'uname -m' returns aarch64.
So, does anyone have an idea of how to get a full-sized version of docker-compose instead of the 9kb file?
Thanks!
followed the link to install the docker-compose link
Basically, thee are only two steps as below:
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
Amazon Linux is "just" the OS, but compiled binaries also depend on your processor architecture. For instance, EC2 t3a series are based on x86_64 architecture wheras the new t4g types are of aarch64 (which is the reason I run into as similar issue as you and ended up here). uname -m returns that identifier, in your case apparently aarch64.
Since the docker-compose github repo contains no released binary for this architeture (as opposed to x86_64), the resolved full download URL returns a "Not found" body instead of the expected binary, thus the described error message when you try to execute it.
As you already found out, there a multiple threads which discuss this issue. The only thing that eventually worked for me was to install docker-compose manually via python's packaga manager pip. Since this approach involves a couple of compilation steps, you need to add various additional OS packages and may face other mostly dependency related errors in the process. But the following steps eventually worked for me:
uname -s -m
1> Linux aarch64
cat /etc/system-release
1> Amazon Linux release 2 (Karoo)
sudo yum install -y python37 \
python3-devel.$(uname -m) libpython3.7-dev \
libffi-devel openssl-devel
# need gcc and friends
sudo yum groupinstall -y "Development Tools"
# make sure pip is up2date
sudo python3 -m pip install -U pip
python3 -m pip install docker-compose
docker-compose --version
1> docker-compose version 1.27.4, build unknown
Hope it works for you as well. Good Luck!
You can start from the scratch on Amazon Linux ec2 instance for installing Docker by following the step:
sudo yum update -y
sudo amazon-linux-extras install docker
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Then logout from the instance and login again to verify the installation of Docker
docker info
To install Docker-compose follow the below steps:
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
I tried everything here mentioned, in the end, it was a problem with the symlink. The official docker page gave me the solution.
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
If it doesn't work after that command, check if you can find docker in your bin folder, e.g. with: ls /usr/local/bin/
If you can see docker-compose there, you almost made it.
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
An easy way to check if docker-compose is there and Linux able to find it, is to use `which docker-compose, also if it is linked correctly, you will get the path to docker-compose as a response.
This worked for me on a AWS EC2 instance with Linux2 as OS.
I faced the same issue. My configuration is T4Large - ARM64 - Ubuntu Server 20.04 LTS and I resolved using the following command
$ sudo apt install docker-compose
This will install the 1.25.0 version of docker compose which is a bit older. At the time of writing this answer the current version is 1.29.1
Another alternative is to use Docker Compose as Docker Container.
Use the following commands to run Docker Compose Container
$ sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
This should work on any Linux distro and on architecture like x86_64, armv7l/armhf, and aarch64/armv8/arm64 if you already have docker installed.
The important point to note is, this runs compose inside a container and does not require installing python on the host system.
Docker hub reference: https://hub.docker.com/r/linuxserver/docker-compose
Installing Docker-Compose in EC2 instance follow below steps
1st command: # sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
2nd command: # sudo chmod +x /usr/local/bin/docker-compose
3rd command: # ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4th Command to verify docker compose: # docker-compose version
It will install latest version of docker-compose. 3rd command is necessary.
This will do everything you need.
Cut. paste. done.
cat ec2-al2-docker-compose.sh
#the following script will install docker and docker compose on amazon linux 2
# run this script then
# sudo docker ps; docker-compose up
# note docker-compose up doesnt use sudo
sudo yum update -y
sudo yum install docker git -y
sudo usermod -a -G docker ec2-user
id ec2-user
newgrp docker
sudo yum install python3-pip -y
sudo pip3 install docker-compose
sudo systemctl enable docker.service
sudo systemctl start docker.service

lsb_release: command not found in latest Ubuntu Docker container

I just wanted to test something out real quick. So I ran a docker container and I wanted to check which version I was running:
$ docker run -it ubuntu
root#471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root#471bdb08b11a:/#
So I tried installing it (as suggested here):
root#471bdb08b11a:/# apt install lsb_release
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lsb_release
root#471bdb08b11a:/#
Anybody any idea why this isn't working?
It seems lsb_release is not installed.
you can install it via
apt-get update && apt-get install -y lsb-release && apt-get clean all
This error can happen due to uninstalling or upgrading the default python3 program version in ubuntu 16.04
The way to correct this is by reinstalling the original python3 version which comes with ubuntu and relinking again. (in ubuntu 16.04 - the default python3 version is python 3.5
sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.5 /usr/bin/python3
Just use cat /etc/os-release and that should display the OS details.
Screenshot from debian.
Screenshot from ubuntu.
Screenshot from fedora.
lsb_release.py lives in /usr/share/pyshared which to me doesn't look like python3.6 and above is referencing.
I found the following will create a link back from a later Python install to this /usr/share script:
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py
In case one is trying to deal with lsb_release: command not found on fedora or redhat, the package to install is redhat-lsb-core , so sudo dnf install redhat-lsb-core
While writing Dockerfile we can add lsb-release package - like this
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install lsb-release -y \
&& apt-get clean all
Assuming OS is Ubuntu.

Installing MySQL on CentOS using shell script

I am writing a script where I should install MySQL on my Centos hard disk when I run it.
I downloaded the following :
mysql-apt-config_0.8.5-1_all.deb
But I don't figure out how to install it from the shell script.
I am new to Linux and any help is appreciated !!
Since Centos is yum package manager just run the following commands to install MySql
If you are using Centos 7, you need to first add the repository as follows
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
To install MySql on Centos, we run
sudo yum install mysql-server
sudo systemctl start mysqld
Note: .deb files are only used for Debian based Linux Distros. Centos uses .rpm files.
Try to save following command in a shell file(extension with .sh) and run with sudo.
#!/bin/bash**strong text**
export http_proxy= $Write proxy
export https_proxy= $ write proxy
sudo -E yum -y update
sudo -E yum -y install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo -E yum -y update
sudo -E yum -y install mysql-server
sudo systemctl start mysqld
sleep 1s
mysql -u root <<-EOF
UPDATE mysql.user SET Password=PASSWORD('123') WHERE User='root';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE Db='test' OR Db='test_%';
FLUSH PRIVILEGES;
EOF

Installing Docker.io on Ubuntu 14.04LTS

I'm running a virtual machine in Windows Azure with the prebuild image for Ubuntu 14.04 LTS.
When I want to install Docker.io like described here:
http://blog.docker.io/2014/04/docker-in-ubuntu-ubuntu-in-docker/
The installation works but when i`m running:
sudo docker.io pull ubuntu
An error will be thrown:
Cannot connect to the Docker daemon. Is docker -d running on this host?
Can anyone help or has the similar problem?
P.S.: Can anyone with a high reputation create a Tag for Ubuntu-14.04?
Evidently the docker daemon is not running. You wanna check /etc/default/docker.conf for proper configuration and issue
sudo service docker.io start
or
sudo service docker start
depending on how they called the service
Adding myself to the docker group:
sudo usermod -a -G docker myuser
and rebooting the machine worked for me. This solution is discussed in: https://github.com/docker/docker/issues/5314
On Ubuntu 14.04, the docker.io package installs Docker 0.9.1.
According to the documentation, to install the current version use these commands:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install lxc-docker
There is also a simple script available to help with this process:
$ curl -s https://get.docker.io/ubuntu/ | sudo sh
Alternatively, check the azure-docker-registry project for an example of how to automate Azure provisioning and Docker container deployment. For instance, this Ansible playbook:
- name: create docker data directory
file: path=/mnt/data/docker state=directory
- name: store docker files in data disk
file: src=/mnt/data/docker dest=/var/lib/docker state=link
- name: add repository key
command: creates=/etc/apt/sources.list.d/docker.list apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
- name: copy repository source file
copy: src=docker.list dest=/etc/apt/sources.list.d/docker.list
- name: install docker package
apt: name=lxc-docker update_cache=yes state=present
Also make sure to symlink the docker.io binary to docker to use the tutorials/documentation without rewriting every command.
ln -s /usr/bin/docker.io /usr/bin/docker
Run docker -d to see if it shows any error messages.
If apparmor is missing install it with sudo apt-get install apparmor
Then sudo service docker start
Hard to say but sometime official docker installation procedure fails on Ubuntu 14.04.
One can simply install docker using below given commands [Quick and Dirty]
sudo apt-get update
sudo apt-get -y install docker.io

Resources