diff --git a/Pipfile b/Pipfile index f48e0fe..fcb4d84 100644 --- a/Pipfile +++ b/Pipfile @@ -7,9 +7,9 @@ name = "pypi" pre_commit = "*" [packages] -molecule = "*" -docker-py = "*" +molecule = {extras = ["docker"],version = "*"} ansible-lint = "*" +yamllint = "*" [requires] python_version = "2.7" diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 index 19692c2..74c703e 100644 --- a/molecule/default/Dockerfile.j2 +++ b/molecule/default/Dockerfile.j2 @@ -5,10 +5,17 @@ FROM {{ item.registry.url }}/{{ item.image }} {% else %} FROM {{ item.image }} {% endif %} - +ENV ANSIBLE_USER=ansible SUDO_GROUP=wheel DEPLOY_GROUP=deployer RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ - elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python3 sudo python3-devel python3-dnf bash && dnf clean all \ + && set -xe \ + && groupadd -r ${ANSIBLE_USER} \ + && groupadd -r ${DEPLOY_GROUP} \ + && useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \ + && usermod -aG ${SUDO_GROUP} ${ANSIBLE_USER} \ + && usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \ + && sed -i "/^%${SUDO_GROUP}/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python firewalld sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..a1c5374 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,20 @@ +--- + +- hosts: CentOS_7 + tasks: + - name: remove requiretty from /etc/sudoers + lineinfile: + dest: "/etc/sudoers" + regexp: "requiretty$" + state: absent + +- hosts: all + become: yes + any_errors_fatal: true + pre_tasks: + - debug: + msg: "wildfly_remove_download_file is {{ wildfly_remove_download_file }}" + - debug: + msg: "wildfly_version is {{ wildfly_version }}" + roles: + - role: inkatze.wildfly diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 6eeea3e..3e766e6 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,15 +5,6 @@ driver: name: docker platforms: - - name: wildfly-centos6-8.2.1 - image: centos:6.8 - - - name: wildfly-centos6-9.0.1 - image: centos:6.8 - - - name: wildfly-centos6-10.1.0 - image: centos:6.8 - - name: wildfly-centos7-8.2.1 image: milcom/centos7-systemd:latest privileged: True @@ -26,12 +17,14 @@ platforms: image: milcom/centos7-systemd:latest privileged: True -ansible: - playbook: playbook.yml - -lint: - name: yamllint - enabled: False + - name: wildfly-centos8-20.0.1 + image: centos:8 + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro provisioner: name: ansible @@ -59,6 +52,9 @@ provisioner: wildfly_version: 9.0.1.Final wildfly-centos7-10.1.0: wildfly_version: 10.1.0.Final + wildfly-centos8-20.0.1: + ansible_user: ansible + wildfly_version: 20.0.1.Final group_vars: all: wildfly_remove_download_file: False @@ -75,8 +71,10 @@ provisioner: SHUTDOWN_WAIT: 2 wildfly_temp_dir: /opt/wildfly/standalone/tmp - lint: - name: ansible-lint + lint: | + set -e + yamllint . + ansible-lint scenario: name: default diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml deleted file mode 100644 index 5fb9c4f..0000000 --- a/molecule/default/playbook.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- - -- hosts: all - tasks: - - debug: - msg: "System {{ inventory_hostname }} has OS {{ ansible_distribution}}-{{ ansible_distribution_major_version }}" - -- hosts: all - tasks: - - name: create a group of all hosts by operating system - group_by: - key: "{{ ansible_distribution}}-{{ ansible_distribution_major_version }}" - -- hosts: CentOS-6 - tasks: - - name: install initscripts - package: - name: initscripts - state: present - -- hosts: CentOS-7 - tasks: - - name: remove requiretty from /etc/sudoers - lineinfile: - dest: "/etc/sudoers" - regexp: "requiretty$" - state: absent - -- hosts: all - any_errors_fatal: true - pre_tasks: - - debug: - msg: "wildfly_remove_download_file is {{ wildfly_remove_download_file }}" - - debug: - msg: "wildfly_version is {{ wildfly_version }}" - roles: - - role: inkatze.wildfly diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..b555373 --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: all + tasks: + - debug: + msg: "System {{ inventory_hostname }} has OS {{ ansible_distribution}}-{{ ansible_distribution_major_version }}" + +- hosts: all + tasks: + - name: create a group of all hosts by operating system + group_by: + key: "{{ ansible_distribution}}_{{ ansible_distribution_major_version }}" \ No newline at end of file