Skip to content

Instantly share code, notes, and snippets.

@akaron
Last active January 6, 2021 04:13
Show Gist options
  • Save akaron/7afcce8f1a8740f0e76caf7fa0b4a9ba to your computer and use it in GitHub Desktop.
Save akaron/7afcce8f1a8740f0e76caf7fa0b4a9ba to your computer and use it in GitHub Desktop.
Use ansible to install ansible in another ubuntu machine (such as a Vagrant provisioned VM)
---
- hosts: master1
become: yes
vars:
- user_name: vagrant
tasks:
- name: install python virtualenv
block:
- name: install python virtualenv
apt:
pkg:
- virtualenv
state: present
register: apt_status
until: apt_status is success
delay: 6
retries: 5
rescue:
- debug: var=apt_status
- apt: name=virtualenv, state=present
- name: Install ansible
become_user: "{{ user_name }}"
pip:
name:
- ansible
- openshift
- pyyaml
virtualenv: /home/{{ user_name }}/venv
virtualenv_python: /usr/bin/python3
- name: Switch to the Virtualenv by default
lineinfile:
path: /home/{{ user_name }}/.bashrc
line: |
source /home/{{ user_name }}/venv/bin/activate
export KUBECONFIG=/home/{{ user_name }}/.kube/config
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment