Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible Community Instruqt tracks #46

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions images/ansible-community.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
source "googlecompute" "ansible-community" {
project_id = "angelic-hold-338616"
source_image = "centos-stream-8-v20220128"
ssh_username = "devops"
zone = "us-east1-d"
machine_type = "n1-standard-1"
image_name = "ansible-community"
}


build {
sources = ["sources.googlecompute.ansible-community"]

provisioner "ansible" {
playbook_file = "./ansible/ansible-setup.yml"
user = "devops"
}
}
24 changes: 0 additions & 24 deletions images/ansible.pkr.hcl

This file was deleted.

165 changes: 28 additions & 137 deletions images/ansible/ansible-setup.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,20 @@
---
- name: download aap.tar.gz to install controller
hosts: localhost
gather_facts: false
vars:
tasks:
- name: download aap
vars:
offline_token: "{{ lookup('file', 'offline_token.txt')}}"
include_role:
name: ansible.workshops.aap_download

- name: copy AAP tar.gz
copy:
src: '{{ playbook_dir }}/aap.tar.gz'
dest: /tmp/aap.tar.gz

- name: configures ansible node
hosts: all
hosts: localhost
connection: local
become: true
vars:
- admin_password: 'ansible123!'

tasks:

# - name: Install useful packages
# include_tasks: "./roles/control_node/tasks/package_dependencies.yml"

- name: Configure user 'rhel'
- name: Configure user 'devops'
ansible.builtin.user:
name: rhel
name: devops
shell: /bin/bash
password: "{{ 'ansible123!' | password_hash('sha512', 'mysecretsalt') }}"
groups: wheel
append: yes

- name: Create test directory
ansible.builtin.file:
path: /home/rhel/test
state: directory
owner: rhel
group: rhel

- name: Create test inventory
ansible.builtin.copy:
dest: /home/rhel/test/hosts
content: |
[rhel]
node1 ansible_user=rhel ansible_password=ansible123!
owner: rhel
group: rhel

- name: Create test playbook
ansible.builtin.copy:
dest: /home/rhel/test/test.yml
content: |
---
- name: test playbook
hosts: rhel
owner: rhel
group: rhel

- name: enable sshd password auth
lineinfile:
dest: /etc/ssh/sshd_config
Expand All @@ -72,97 +27,33 @@
ansible.builtin.systemd:
name: sshd
state: restarted

# - name: DNF update the system
# dnf:
# name: "*"
# state: latest

- name: create repo
yum_repository:
name: aap_installer
description: aap_installer
baseurl: file:///temp_dir/aap_install/bundle/el8/repos
gpgcheck: no
- name: Create temp_dir
file: path=/temp_dir/aap_install state=directory

- name: copy /tmp/aap_download to temp_dir
copy:
src: /tmp/aap.tar.gz
dest: /temp_dir

- name: Extract AAP tar.gz install
unarchive:
src: /temp_dir/aap.tar.gz
dest: /temp_dir/aap_install
remote_src: true
extra_opts: ['--strip-components=1', '--show-stored-names']

- name: Install EPEL
dnf:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm"
state: present
disable_gpg_check: true

- name: Install required packages
yum:
name: "{{ item }}"
state: latest
loop:
- podman
- ansible-builder
- ansible-navigator
- ansible-core
dnf:
name:
- vim
- git
- wget
- nano
- tree
- sshpass
- tmux
- emacs
- gcc
- bind-utils
state: present
register: dnf_check
until: dnf_check is not failed
retries: 4
delay: 5

- name: install code server
vars:
username: "{{ ansible_user }}"
username: 'devops'
include_tasks: "./roles/code_server/tasks/codeserver.yml"

# - name: remove dnf automatic
# package:
# name: dnf-automatic
# state: absent

# Stop dnf auto updates
- name: disable dnf automatic services
ansible.builtin.service:
name: "{{ item }}"
state: stopped
loop:
- dnf-automatic.timer

- name: automatic.conf disable downloads
ansible.builtin.lineinfile:
path: /etc/dnf/automatic.conf
regexp: '^download_updates'
line: download_updates = no

- name: automatic.conf disable updates
ansible.builtin.lineinfile:
path: /etc/dnf/automatic.conf
regexp: '^apply_updates'
line: apply_updates = no

- name: Disable RHUI repos
ansible.builtin.command: >
dnf config-manager --set-disabled rhui*


## Execution environments
- name: Pull EEs in rhel user
hosts: all
become_user: rhel
tasks:
- name: include red hat crednetial for registry.redhat.io
include_vars:
file: redhat_login.yml

- name: Login to redhat registry
containers.podman.podman_login:
username: '{{ your_username }}'
password: '{{ your_password }}'
registry: registry.redhat.io

- name: Pull an image
containers.podman.podman_image:
name: "{{ item }}"
loop:
- registry.redhat.io/ansible-automation-platform-20-early-access/ee-minimal-rhel8:2.0.0
- registry.redhat.io/ansible-automation-platform-20-early-access/ansible-builder-rhel8:2.0.0
- registry.redhat.io/ansible-automation-platform-20-early-access/ee-supported-rhel8:2.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

pip3 install ansible-core

echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" > /etc/sudoers.d/sudo_secure_path
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2"
virtualmachines:
- name: shell
image: centos-cloud/centos-8
shell: /usr/bin/su - devops
machine_type: n1-standard-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

pip3 install --upgrade pip