The ansible playbook helps you create and configure a base vm environment. So you can connect this playbook with your normal dockerBuild task and it helps automate the rest of steps to tag/deploy the image.
-
Use the generic OS package manager pakcage module to install generic packages.
-
Separate OS-specific packages into different files and include them dynamically.
- import_tasks: install_darwin.yml
when: ansible_facts['os_family'] == "Darwin"
- import_tasks: install_linux.yml
when: ansible_facts['os_family'] == "ArchLinux"
- import_tasks: config.yml
- Organize related installation and configuration as roles
Make sure you have ansible
installed, and you are connected to p2 environment, and the kubectl
works for deployment updates.
brew install ansible # for Mac
## Clone the repo
git clone git@github.com:mingliangguo/ansible-playground.git
# add an alias to your .bashrc / .zshrc
alias cd $YOUR_CLONE_FOLDER && ansible-playbook -i inventory.ini deploy-kube-service.yml
Use
ansible-galaxy install -r requirements.yam
or install them individually:
ansible-galaxy install nover.ohmyzsh
ansible-galaxy install geerlingguy.nodejs
ansible-galaxy install andrewrothstein.yarn
ansible-galaxy install geerlingguy.docker
ansible-galaxy install andrewrothstein.kind
ansible-galaxy collection install community.general
See how the role is used in configure-vm.yml
roles:
- { role: nover.ohmyzsh, ohmyzsh_theme: 'robbyrussell', become: true }
- Create a VM using vagrant (or any other tool to create a base vm)
- Install
openssh-server
so a remote user can ssh to the host
sudo apt install openssh-server -y
# the following might be needed on fedora
sudo systemctl enable sshd
sudo systemctl restart sshd
- Then use
configure-user.yml
playbook to configure a non-root user account on the vm, and it will ask you the password of your root account: or create your own user and then use the same playbook to add the user to the sudoer list
adduser your_user_name
ssh-copy-id -i path/to/certificate username@remote_host
The steps above can actually be achieved via the following playbook:
Once you get the vm setup, you can add the following entry to sandbox.ini
vm-host ansible_user=root ansible_host=vm-host
Then use configure-user.yml
playbook to configure a non-root user account on the vm, and it will ask you the password of your root account (or supply the password for the non-root user):
ansible-playbook -i sandbox.ini playbooks/configure-user.yml -e host_name=vm-host -e user_name=gary -kK
ansible-playbook -i sandbox.ini playbooks/configure-user.yml -e host_name=vm-host -e user_name=gary --extra-vars "ansible_sudo_pass=yourPassword"
-k
, --ask-pass: ask for connection password-K
, --ask-become-pass: ask for privilege escalation password
Note: The detail information about the gary-dev1
host is in the sandbox.ini
file. Make sure password-less ssh and sudo are enabled on the host.
usermod -aG sudo username
Then configure password-less sudo.
Edit /etc/sudoers
file and add a line as below for the user you want to allow nopassword sudo.
Refer to:
sudo cp /etc/sudoers ~/sudoers.bak
sudo visudo
# Add the following line to the sudoers file
user_name ALL=(ALL) NOPASSWD:ALL
edit /etc/pam.d/sudo
file and add the following line at the beginning of the file:
auth sufficient pam_tid.so
The full file might look like this:
# sudo: auth account password session
auth sufficient pam_tid.so
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
Check this SO question for reference.
Note: There is a special configuration for iTerm, also mentioned in the above answers.
Here are some tips to make sure virtualbox works properly in Windows.
- disable hyper-v
- use
ICH9
chipset - disable
PAE/NX