diff --git a/CHANGELOG b/CHANGELOG index 3451cbf..22aff57 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +1.8.1: +* update to molecule 3 and fix gevent install 1.8.0: * upgrade to 0.6.6 see #15 https://github.com/CoffeeITWorks/ansible_burpui_server/issues/15 diff --git a/defaults/main.yml b/defaults/main.yml index 24f7d4e..84464f3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,9 +24,8 @@ burpui_pip_present: - "Flask-Session" - "Flask-Migrate" - "celery>=4.0.2" - - "pip>=9" - "cffi>=1.7" - - "gevent>=1.2" + - "gevent>=20.0.5" - "ujson>=1.35" - "urllib3>=1.19" # required to avoid issues with get_url module # - "ndg-httpsclient>=0.4.2" # required to avoid issues with get_url module diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 deleted file mode 100644 index f8b4e75..0000000 --- a/molecule/default/Dockerfile.j2 +++ /dev/null @@ -1,9 +0,0 @@ -# Molecule managed - -FROM {{ item.image }} - -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 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; fi diff --git a/molecule/default/playbook.yml b/molecule/default/converge.yml similarity index 69% rename from molecule/default/playbook.yml rename to molecule/default/converge.yml index 46c86bd..605331c 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/converge.yml @@ -4,9 +4,9 @@ vars: burpui_standalone: True burpui_pip_burpui_dev: 'git+https://git.ziirish.me/ziirish/burp-ui.git@stable#egg=burp-ui' - burpui_use_dev: True + #burpui_use_dev: True # now in molecule.yml inventory group_vars roles: - - role: ansible_burp2_server + - role: coffeeitworks.burp2_server - role: ansible_burpui_server tags: - burpui-server diff --git a/molecule/default/create.yml b/molecule/default/create.yml deleted file mode 100644 index bfb2149..0000000 --- a/molecule/default/create.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" - molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" - molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" - tasks: - - name: Create Dockerfiles from image names - template: - src: "{{ molecule_scenario_directory }}/Dockerfile.j2" - dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" - with_items: "{{ molecule_yml.platforms }}" - register: platforms - - - name: Discover local Docker images - docker_image_facts: - name: "molecule_local/{{ item.item.name }}" - with_items: "{{ platforms.results }}" - register: docker_images - - - name: Build an Ansible compatible image - docker_image: - path: "{{ molecule_ephemeral_directory }}" - name: "molecule_local/{{ item.item.image }}" - dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" - force: "{{ item.item.force | default(true) }}" - with_items: "{{ platforms.results }}" - when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 - - - name: Create molecule instance(s) - docker_container: - name: "{{ item.name }}" - hostname: "{{ item.name }}" - image: "molecule_local/{{ item.image }}" - state: started - recreate: false - log_driver: syslog - command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" - privileged: "{{ item.privileged | default(omit) }}" - volumes: "{{ item.volumes | default(omit) }}" - capabilities: "{{ item.capabilities | default(omit) }}" - ports: "{{ item.exposed_ports | default(omit) }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: docker_jobs - until: docker_jobs.finished - retries: 300 - with_items: "{{ server.results }}" diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml deleted file mode 100644 index 3ce7478..0000000 --- a/molecule/default/destroy.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(true) }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: docker_jobs - until: docker_jobs.finished - retries: 300 - with_items: "{{ server.results }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 2995899..5b8a076 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,51 +4,61 @@ dependency: options: ignore-certs: True ignore-errors: True - role-file: requirements.yml + role-file: requirements.yml # this file is at the root of the git project same place as molecule is executed driver: name: docker -lint: - name: yamllint platforms: - - name: ansible_test-01 - image: paulfantom/debian-molecule:9 - privileged: True + + - name: ansible_burpui_server-01 + image: "geerlingguy/docker-ubuntu1804-ansible:latest" + #privileged: True + command: /sbin/init + pre_build_image: true capabilities: - - SYS_ADMIN + - SYS_ADMIN + tmpfs: + - /run + - /tmp volumes: - - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" groups: - - group1 - - name: ansible_test-02 - image: fedora - privileged: True + - use_pip_package + + - name: ansible_burpui_server-02 + image: "geerlingguy/docker-debian9-ansible" + #privileged: True + command: /sbin/init + pre_build_image: true capabilities: - - SYS_ADMIN + - SYS_ADMIN + tmpfs: + - /run + - /tmp volumes: - - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" groups: - - group1 - # In docker cannot be tested with centos 7 due to https://github.com/ansible/ansible-modules-core/issues/593 - - name: ansible_test-03 - image: centos/systemd + - use_pip_package + + - name: ansible_burpui_server-03 + image: docker.io/pycontribs/centos:7 + pre_build_image: true command: /sbin/init capabilities: - SYS_ADMIN volumes: - "/sys/fs/cgroup:/sys/fs/cgroup:ro" - privileged: True + #privileged: True groups: - - group1 + - use_dev_package + provisioner: name: ansible config_options: defaults: callback_whitelist: profile_tasks - lint: - name: ansible-lint -scenario: - name: default -verifier: - name: testinfra - lint: - name: flake8 + inventory: + group_vars: + use_pip_package: + burpui_use_dev: False + use_dev_package: + burpui_use_dev: True diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml deleted file mode 100644 index 5358b3b..0000000 --- a/molecule/default/prepare.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: false - tasks: [] diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..a82dd6f --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,9 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + tasks: + - name: Example assertion + assert: + that: true diff --git a/requirements.yml b/requirements.yml index b8f20e1..5747443 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,4 +1,4 @@ # from galaxy - src: CoffeeITWorks.burp2_server - name: ansible_burp2_server + name: coffeeitworks.burp2_server version: master diff --git a/run_local_molecule.sh b/run_local_molecule.sh index 4169a26..2350cb3 100644 --- a/run_local_molecule.sh +++ b/run_local_molecule.sh @@ -1,3 +1,4 @@ +# Fedora local docker: https://success.docker.com/article/firewalld-problems-with-container-to-container-network-communications # https://molecule.readthedocs.io/en/latest/examples.html#docker docker run --rm -it --privileged=True \ -v "$(pwd)":/tmp/$(basename "${PWD}"):ro \ diff --git a/tasks/main.yml b/tasks/main.yml index 58101d9..741d0db 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -68,7 +68,7 @@ - include_tasks: gunicorn.yml - include_tasks: bui-celery.yml - when: burpui_production_celery + when: burpui_production_celery | bool # This is prepared for next 0.5.0 version - include_tasks: bui-upgrade.yml diff --git a/tasks/python3_pip.yml b/tasks/python3_pip.yml index 27797f1..910a428 100644 --- a/tasks/python3_pip.yml +++ b/tasks/python3_pip.yml @@ -8,6 +8,12 @@ register: burpui_installed_check check_mode: yes +- name: pip3 | update pip + pip: + name: 'pip>=20' + state: present + executable: "{{ python3_pip }}" + - name: pip3 | install pip packages pip: name: '{{ burpui_pip_present }}' diff --git a/tasks/systemd.yml b/tasks/systemd.yml index 5bc093a..57b266f 100644 --- a/tasks/systemd.yml +++ b/tasks/systemd.yml @@ -25,5 +25,16 @@ state: started enabled: yes +# redis-server systemd ubuntu +- name: systemd | fix redis-server setup for systemd + lineinfile: + dest: "/etc/redis/redis.conf" + regexp: "{{ item.src }}" + line: "{{ item.value }}" + with_items: + - { src: '^supervised ' , value: 'supervised systemd' } + - { src: '^bind ' , value: 'bind 127.0.0.1' } + when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int >= 18 + - name: flush handlers meta: flush_handlers diff --git a/vars/Debian.yml b/vars/Debian.yml index 3375f5f..ddc46ce 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -6,6 +6,7 @@ burpui_system_absent: - python3-cryptography +# For python2 burpui_system_requirements: - python-pip - python-setuptools @@ -14,6 +15,10 @@ burpui_system_requirements: - libffi-dev # dependency for cffi - locales-all # required for python3 - gcc + - libev-dev # required for gevent + - musl-dev # required for gevent + - libevent-dev # required for gevent + - tzdata # required timezone installed for gunicorn burpui_py3_packages: - python3 @@ -24,6 +29,10 @@ burpui_py3_packages: - libffi-dev # dependency for cffi - locales-all # required for python3 - gcc + - libev-dev # required for gevent + - musl-dev # required for gevent + - libevent-dev # required for gevent + - tzdata # required timezone installed for gunicorn burpui_packages: - redis-server