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
- name: Copy file Lab folder with owner and permissions | |
ansible.builtin.copy: | |
src: "{{ playbook_dir }}/lab" | |
dest: "/home/{{ ansible_user }}" | |
owner: "{{ ansible_user }}" | |
group: "{{ ansible_user }}" | |
mode: '0755' |
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
- name: Ensure group "docker" exists | |
ansible.builtin.group: | |
name: docker | |
state: present | |
- name: Append user {{ ansible_user }} to the group 'docker' | |
ansible.builtin.user: | |
name: "{{ ansible_user }}" | |
groups: docker | |
append: yes |
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
- name: Install Docker | |
ansible.builtin.package: | |
name: | |
- docker-ce | |
- docker-ce-cli | |
- containerd.io | |
state: present | |
- name: Ensure Docker is started and enabled at boot | |
ansible.builtin.service: |
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
- name: Download Go | |
ansible.builtin.get_url: | |
url: "{{ go_download_url }}" | |
dest: "/tmp/go{{ go_version }}.tar.gz" | |
mode: '0644' | |
- name: Unarchive Go | |
ansible.builtin.unarchive: | |
src: "/tmp/go{{ go_version }}.tar.gz" | |
dest: "/usr/local" |
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
- name: Install base packages | |
ansible.builtin.package: | |
name: "{{ common_software }}" | |
state: present |
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
python_libraries: | |
- ipaddress |
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
common_software: | |
- git | |
- wget | |
- tree | |
- tar | |
- python3-pip | |
- ansible |
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
- name: Setup hostname | |
ansible.builtin.hostname: | |
name: "{{ hostvars[inventory_hostname] }}" |
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
- name: Add instance(s) to my_instances group | |
ansible.builtin.add_host: | |
name: "{{ item.tags.Name }}" | |
ansible_host: "{{ item.public_ip_address }}" | |
ansible_user: "{{ ec2_username }}" | |
private_ip: "{{ item.private_ip_address }}" | |
instance_name: "{{ ec2_resource_prefix }}" | |
ansible_ssh_private_key_file: "{{ playbook_dir }}/{{ ec2_resource_prefix }}-private.pem" | |
instance_ssh: "{{ ssh_info }}" | |
groups: |
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
- name: Wait until we can SSH to the instance | |
ansible.builtin.wait_for: | |
host: "{{ ec2.instances[0].public_ip_address }}" | |
port: 22 | |
state: started |