I'm following a blog to Deploy a Debian Linux VM Instance in GCP using Terraform, in which it uses metadata_startup_script Bootstrapping Script to Install/config packages.
I'm following in Azure instead of GCP, and got:
An argument named "metadata_startup_script" is not expected here.
Is metadata_startup_script GCP provider speicific? What's the corresponding mechanism in the terraform Azure provider ? For e.g. to do the following,
sudo apt-get update;
sudo apt-get install -y apache2;
sudo systemctl start apache2;
sudo systemctl enable apache2;
to bootstrap the provided Linux VM?
The attribute metadata_startup_script doesn't exist on Azure VMs, its similar is user_data[1].
References:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine#user_data
Related
Goal:
We are creating dev environments for developers in GCP cloud.
Every developer would have a dedicated Linux VM in GCP for day to day development tasks & testing
Linux VM is a dev environment(with multiple tools installed for source code checkout etc...). Docker daemon is another tool, needed, for day to day tasks.
So, Linux VM should have docker daemon(installed) to launch docker containers(for testing).
Can we install docker daemon on Linux VM? if yes, please provide steps..
When I build VMs for developers that require Docker, I use a startup script so that Docker is installed when the VM is created. This script can also be used in a terminal window to manually install Docker.
This script is for Debian/Ubuntu systems.
One variable is required. $USER needs to be added to the docker group so that users can run containers without sudo permissions. This script runs commands with sudo which is not required as a startup script but is required for a normal user.
#!/bin/bash -v
sudo apt update
sudo apt upgrade -y
sudo apt install apt-transport-https -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce -y
sudo usermod -aG docker ${USER}
echo "User ${USER} added to docker group. Re-login to assume docker group membership."
You can refer the document provided by digital ocean.
I was able to successfully setup docker using the above and once docker is installed, make sure to add your user into docker group. Please refer this link for post installation tasks.
I am struggling to install Azure CLI on a Ubuntu machine without root access.
The instructions here assume that we have root access (or reasonable sudo access).
I am trying to run this on a Ubuntu machine (provided by IBM DevOps toolchain - root access will never be granted) where executing the sudo command results in:
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
This results in sudo: no tty present and no askpass program specified
Why do I need a tty to run sudo? has some answers however I am not able to use them as I don't have control over the login to the shell via ssh.
I am using the IBM Cloud's DevOps toolchain to deploy applications to both IBM Cloud and Azure.
The DevOps toolchain provides me a shell for me to execute commands.
Are there other alternatives
Assuming that you have the required prerequisites installed, you can either use the script or plain 'ole pip to install the Azure CLI (pip install azure-cli). Personally, I often use the docker container as well.
Have you tried running the script as documented,
curl -L https://aka.ms/InstallAzureCli | bash
I do not see why sudo would be required to install az. The install script downloads a python script (this one) and runs it. This script basically
Downloads virtualenv
creates a virtual env at ~/lib/azure-cli
calls pip install azure-cli on that virtual env
writes a a shell script to ~/bin/az named az that runs python -m azure.cli and give it some permissions
adds completion (tab) to az
Based on my knowledge, this is possible. Root permission is required. You could check this answer to solve your issue, but I think you should have root permission to do this.
If possible, I suggest you could use Azure Cloud Shell to run cli command on Azure.
I followed the guide here to update waagent using this command:
sudo yum install waagent
However my server is unable to find the package. The reason why I want to update the package is because I'm unable to setup backup. Whenever I try, I'll get an error "VM agent is unable to communicate with the Azure Backup Service". Below is the screenshot.
Azure Operation Error
Edit: My virtual machine is not set up in the classic environment.
On CentOS or RHEL you have to execute
sudo yum update WALinuxAgent
to update the waagent.
You can check that the update was successful by calling waagent --version
I decided to update waagent manually using the guide from the link I provided. After that I'm able to setup and run backups without problem.
I am trying to set up remote Ubuntu desktop on Azure free tire. I have followed all the steps mentioned in here and Azure Documentation. I have setup instance with resources manager. Setup the rdp. Install xrdp via ssh. Install Ubuntu desktop as well.
Installed -- Ubuntu Server 16.04 LTS
Also installed xfce as mentioned in Azure Documentation
In-spite of installing everything properly I see dotted screen when I connected remotely. What am I doing wrong ?
Using xfce if you are using Ubuntu version later than Ubuntu 12.04LTS
We can follow those steps to install xrdp:
sudo -i
1.Install XRDP Package from Ubuntu Repository
apt-get install xrdp
2.Installing the xfce4 Desktop environment
apt-get update
apt-get install xfce4
3.Configure xrdp to use xfce desktop environment
echo xfce4-session >~/.xsession
4.Restart xrdp service
service xrdp restart
5.Test your xrdp connection:
We can use mstsc to test xrdp connection.
Note:
If you use this command apt-get install xfce4 get this error message:
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
Please add ARRAY <ignore> devices=/dev/sda to /etc/mdadm/mdadm.conf, like this:
root#ubuntu:~# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#
ARRAY <ignore> devices=/dev/sda
# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
More information about xrdp on azure vm, please refer to this link.
I have been trying to do a Docker and Kubernetes setup on Linux on aws but I am unable to do the same.
yum install -y docker docker-registry etcd kubernetes flannel
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
No package docker available.
No package docker-registry available.
No package kubernetes available.
No package flannel available.
Can anyone suggest a common repo and set of repos that i need to add to get this setup done?
Note: Subscription manager isnt an option as this servers are provisioned via AWS
Try installing using this command instead of sudo yum
curl -sSL https://get.docker.com/ | sh