Skip to content

Commit

Permalink
https://github.com/ansible/ansible-lint/pull/2527
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Oct 2, 2022
1 parent d231adb commit 44032ae
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 79 deletions.
139 changes: 77 additions & 62 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,46 @@
gather_facts: false
tasks:
- name: redhat | subscription-manager register
ansible.builtin.raw: |
set -eu
subscription-manager register \
--username={{ lookup('env', 'REDHAT_USERNAME') }} \
--password={{ lookup('env', 'REDHAT_PASSWORD') }} \
--auto-attach
ansible.builtin.raw:
cmd: |
set -eu
subscription-manager register \
--username={{ lookup('env', 'REDHAT_USERNAME') }} \
--password={{ lookup('env', 'REDHAT_PASSWORD') }} \
--auto-attach
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: debian | apt-get install python3
ansible.builtin.raw: |
set -eu
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3
ansible.builtin.raw:
cmd: |
set -eu
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: redhat | yum install python3
ansible.builtin.raw: |
set -eu
yum makecache
yum install -y python3
ansible.builtin.raw:
cmd: |
set -eu
yum makecache
yum install -y python3
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: suse | zypper install python3
ansible.builtin.raw: |
set -eu
zypper -n --gpg-auto-import-keys refresh
zypper -n install -y python3
ansible.builtin.raw:
cmd: |
set -eu
zypper -n --gpg-auto-import-keys refresh
zypper -n install -y python3
args:
executable: "/bin/bash"
changed_when: false
Expand All @@ -68,115 +72,126 @@
become: true
tasks:
- name: cp -rfT /etc/skel /root
ansible.builtin.raw: |
set -eu
cp -rfT /etc/skel /root
rm -rf /root/.bash_logout
ansible.builtin.raw:
cmd: |
set -eu
cp -rfT /etc/skel /root
rm -rf /root/.bash_logout
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: setenforce 0
ansible.builtin.raw: |
set -eu
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=permissive/g' /etc/selinux/config
ansible.builtin.raw:
cmd: |
set -eu
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=permissive/g' /etc/selinux/config
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: systemctl stop iptables.service
ansible.builtin.raw: |
set -eu
systemctl stop iptables.service
systemctl disable iptables.service
ansible.builtin.raw:
cmd: |
set -eu
systemctl stop iptables.service
systemctl disable iptables.service
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: systemctl stop firewalld.service
ansible.builtin.raw: |
set -eu
systemctl stop firewalld.service
systemctl disable firewalld.service
ansible.builtin.raw:
cmd: |
set -eu
systemctl stop firewalld.service
systemctl disable firewalld.service
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: systemctl stop ufw.service
ansible.builtin.raw: |
set -eu
systemctl stop ufw.service
systemctl disable ufw.service
ansible.builtin.raw:
cmd: |
set -eu
systemctl stop ufw.service
systemctl disable ufw.service
args:
executable: "/bin/bash"
changed_when: false
failed_when: false

- name: debian | apt-get install *.deb
ansible.builtin.raw: |
set -eu
DEBIAN_FRONTEND=noninteractive apt-get install -y bzip2 ca-certificates curl gcc gnupg gzip hostname iproute2 passwd procps python3 python3-apt python3-jmespath python3-lxml python3-pip python3-setuptools python3-venv python3-virtualenv python3-wheel rsync sudo tar unzip util-linux xz-utils zip
ansible.builtin.raw:
cmd: |
set -eu
DEBIAN_FRONTEND=noninteractive apt-get install -y bzip2 ca-certificates curl gcc gnupg gzip hostname iproute2 passwd procps python3 python3-apt python3-jmespath python3-lxml python3-pip python3-setuptools python3-venv python3-virtualenv python3-wheel rsync sudo tar unzip util-linux xz-utils zip
args:
executable: "/bin/bash"
when: ansible_os_family | lower == "debian"
changed_when: false
failed_when: false

- name: fedora | yum install *.rpm
ansible.builtin.raw: |
set -eu
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
ansible.builtin.raw:
cmd: |
set -eu
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
args:
executable: "/bin/bash"
when: ansible_distribution | lower == "fedora"
changed_when: false
failed_when: false

- name: redhat-9 | yum install *.rpm
ansible.builtin.raw: |
set -eu
yum-config-manager --enable crb || echo $?
yum-config-manager --enable codeready-builder-for-rhel-9-x86_64-rpms || echo $?
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
ansible.builtin.raw:
cmd: |
set -eu
yum-config-manager --enable crb || echo $?
yum-config-manager --enable codeready-builder-for-rhel-9-x86_64-rpms || echo $?
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
args:
executable: "/bin/bash"
when: ansible_os_family | lower == "redhat" and ansible_distribution_major_version | lower == "9"
changed_when: false
failed_when: false

- name: redhat-8 | yum install *.rpm
ansible.builtin.raw: |
set -eu
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
ansible.builtin.raw:
cmd: |
set -eu
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-dnf-plugin-versionlock python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-utils zip
args:
executable: "/bin/bash"
when: ansible_os_family | lower == "redhat" and ansible_distribution_major_version | lower == "8"
changed_when: false
failed_when: false

- name: redhat-7 | yum install *.rpm
ansible.builtin.raw: |
set -eu
subscription-manager repos --enable=rhel-7-server-optional-rpms || echo $?
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-plugin-versionlock yum-utils zip
ansible.builtin.raw:
cmd: |
set -eu
subscription-manager repos --enable=rhel-7-server-optional-rpms || echo $?
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y bzip2 ca-certificates curl gcc gnupg2 gzip hostname iproute procps-ng python3 python3-jmespath python3-libselinux python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow-utils sudo tar unzip util-linux xz yum-plugin-versionlock yum-utils zip
args:
executable: "/bin/bash"
when: ansible_os_family | lower == "redhat" and ansible_distribution_major_version | lower == "7"
changed_when: false
failed_when: false

- name: suse | zypper -n install *.rpm
ansible.builtin.raw: |
set -eu
zypper -n install -y bzip2 ca-certificates curl gcc gpg2 gzip hostname iproute2 procps python3 python3-jmespath python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow sudo tar unzip util-linux xz zip
ansible.builtin.raw:
cmd: |
set -eu
zypper -n install -y bzip2 ca-certificates curl gcc gpg2 gzip hostname iproute2 procps python3 python3-jmespath python3-lxml python3-pip python3-setuptools python3-virtualenv python3-wheel rsync shadow sudo tar unzip util-linux xz zip
args:
executable: "/bin/bash"
when: ansible_os_family | lower == "suse"
Expand Down
36 changes: 19 additions & 17 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@
until: result is succeeded

- name: download archive
ansible.builtin.shell: |
set -euxo pipefail
mkdir -p /var/log/ansible
exec &> >(tee -a /var/log/ansible/{{ item.checksum }}-get_url.log)
TMP_DIR="$(mktemp -d)" \
&& cd $TMP_DIR \
&& mkdir -p .{{ item.dest | dirname }} \
&& curl -skL -m 300 {{ item.url }} > .{{ item.dest }} \
&& echo -n "{{ item.checksum }} .{{ item.dest }}" | sha256sum -c - \
&& mkdir -p {{ item.dest | dirname }} \
&& mv .{{ item.dest }} {{ item.dest }} \
&& rm -rf $TMP_DIR
ansible.builtin.shell:
cmd: |
set -euxo pipefail
mkdir -p /var/log/ansible
exec &> >(tee -a /var/log/ansible/{{ item.checksum }}-get_url.log)
TMP_DIR="$(mktemp -d)" \
&& cd $TMP_DIR \
&& mkdir -p .{{ item.dest | dirname }} \
&& curl -skL -m 300 {{ item.url }} > .{{ item.dest }} \
&& echo -n "{{ item.checksum }} .{{ item.dest }}" | sha256sum -c - \
&& mkdir -p {{ item.dest | dirname }} \
&& mv .{{ item.dest }} {{ item.dest }} \
&& rm -rf $TMP_DIR
args:
executable: "/bin/bash"
creates: "/var/log/ansible/{{ item.checksum }}-get_url.log"
Expand All @@ -44,11 +45,12 @@
until: result is succeeded

- name: yum install
ansible.builtin.shell: |
set -euxo pipefail
mkdir -p /var/log/ansible
exec &> >(tee -a /var/log/ansible/{{ item.checksum }}-unarchive.log)
yum install -y {{ item.dest }}
ansible.builtin.shell:
cmd: |
set -euxo pipefail
mkdir -p /var/log/ansible
exec &> >(tee -a /var/log/ansible/{{ item.checksum }}-unarchive.log)
yum install -y {{ item.dest }}
args:
executable: "/bin/bash"
creates: "/var/log/ansible/{{ item.checksum }}-unarchive.log"
Expand Down

0 comments on commit 44032ae

Please sign in to comment.