Last active
January 6, 2021 04:13
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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