From e9b8d519f99a2540e0c7b58162563b3748b4d958 Mon Sep 17 00:00:00 2001 From: Arslanbekov Denis Date: Tue, 16 Jan 2018 21:14:45 +0300 Subject: [PATCH 1/5] Add basic check exist docker container selenoid --- tasks/main.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 9ed4136..a79d476 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,17 @@ with_items: - { name: docker-py } +- name: Selenoid | Check selenoid container exist + shell: 'docker ps -aq --filter "name={{ item }}"' + with_items: + - 'selenoid' + register: found_containers + +- name: Selenoid | Remove selenoid container if exist + shell: 'docker stop {{ item.item }} && docker rm -fv {{ item.item }}' + with_items: '{{ found_containers.results }}' + when: item.stdout + - name: Selenoid | Run CM container, download browser images and run selenoid docker_container: name: cm From 638bf9fda08ab8d33671f189981e4712a2db9a45 Mon Sep 17 00:00:00 2001 From: Arslanbekov Denis Date: Thu, 18 Jan 2018 13:56:44 +0300 Subject: [PATCH 2/5] edit travis.yml, add browsers and last-release --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7fba1b4..3b39682 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,8 @@ script: - ansible-playbook -v --diff tests/role.yml - > ansible-playbook tests/role.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) + | grep -q 'failed=0' + && (echo 'Fail test: pass' && exit 0) + || (echo 'Fail test: fail' && exit 1) notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ From a729f95ae2ec42c7b1e2731e968fa84f69fda7d7 Mon Sep 17 00:00:00 2001 From: Arslanbekov Denis Date: Thu, 18 Jan 2018 13:57:07 +0300 Subject: [PATCH 3/5] add browsers and last-release --- tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index a79d476..e191d63 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -33,5 +33,7 @@ --version {{ selenoid_version }} --tmpfs {{ selenoid_tmpfs }} --env DOCKER_API_VERSION={{ selenoid_docker_api_version }} + --browsers firefox,opera,chrome + --last-versions 5 --force --args "-limit {{ selenoid_limit }} -listen :{{ selenoid_listen_port }} -conf {{ selenoid_config_dir }}/browsers.json" From 7e4a2d37ecf72694b5336cb6dceab68c67477804 Mon Sep 17 00:00:00 2001 From: Arslanbekov Denis Date: Thu, 18 Jan 2018 14:07:30 +0300 Subject: [PATCH 4/5] parametrize browsers list --- ansible.cfg | 3 +++ defaults/main.yml | 5 +++++ tasks/main.yml | 4 ++-- tests/inventory | 1 + tests/role.retry | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 ansible.cfg create mode 100644 tests/inventory create mode 100644 tests/role.retry diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..4cf297f --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +roles_path = ../ +hostfile = ./tests/inventory diff --git a/defaults/main.yml b/defaults/main.yml index b900366..dd2b61e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,3 +7,8 @@ selenoid_tmpfs: 128 selenoid_config_dir: /etc/selenoid selenoid_listen_port: 4444 selenoid_time_zone: Europe/Moscow +selenoid_browsers_last_versions: 5 +selenoid_browsers: + - firefox + - opera + - chrome diff --git a/tasks/main.yml b/tasks/main.yml index e191d63..e64b5b6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -33,7 +33,7 @@ --version {{ selenoid_version }} --tmpfs {{ selenoid_tmpfs }} --env DOCKER_API_VERSION={{ selenoid_docker_api_version }} - --browsers firefox,opera,chrome - --last-versions 5 + --browsers {% for browser in selenoid_browsers -%}{{ browser }}{%- if not loop.last -%},{%- endif -%}{%- endfor %} + --last-versions {{ selenoid_browsers_last_versions }} --force --args "-limit {{ selenoid_limit }} -listen :{{ selenoid_listen_port }} -conf {{ selenoid_config_dir }}/browsers.json" diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..03cac36 --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost ansible_connection=local diff --git a/tests/role.retry b/tests/role.retry new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/tests/role.retry @@ -0,0 +1 @@ +localhost From 65f383b657a203aaf9d1e6fe68eb1539189768ae Mon Sep 17 00:00:00 2001 From: Arslanbekov Denis Date: Thu, 18 Jan 2018 14:24:00 +0300 Subject: [PATCH 5/5] Edit readme and fix variables --- README.md | 35 ++++++++++++++++++++--------------- defaults/main.yml | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index c76c50d..a252792 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,21 @@ Set up [selenoid](https://github.com/aerokube/selenoid) in docker #### Variables -* `selenoid_cm_version`: [Default: `1.3.1`] Install configuration manager version -* `selenoid_version`: [Default: `1.4.0`] Install selenoid version -* `selenoid_docker_api_version`: [Default: `1.24`] Docker api version (for Selenoid) -* `selenoid_limit`: [Default: `4`] Total number of simultaneously running containers ([full docs](http://aerokube.com/selenoid/latest/#_recommended_docker_settings)) -* `selenoid_tmpfs`: [Default: `128`] Add in-memory filesystem (tmpfs) to container ([full docs](http://aerokube.com/selenoid/latest/#_other_optional_fields)) -* `selenoid_config_dir`: [Default: `/etc/selenoid`] Selenoid configuration dir -* `selenoid_listen_port`: [Default: `4444`] Listen port -* `selenoid_time_zone`: [Default: `Europe/Moscow`] Timezone in container +```yaml +selenoid_version: 1.4.0 +selenoid_cm_version: 1.3.1 +selenoid_docker_api_version: 1.24 +selenoid_limit: 4 +selenoid_tmpfs: 128 +selenoid_config_dir: /etc/selenoid +selenoid_listen_port: 4444 +selenoid_time_zone: Europe/Moscow +selenoid_browsers_last_versions: 5 +selenoid_browsers: + - firefox + - opera + - chrome +``` #### Example @@ -33,14 +40,12 @@ Set up [selenoid](https://github.com/aerokube/selenoid) in docker * [grid-router](https://github.com/iqoption/gridrouter-ansible) -grid-router may help you generate browser.xml (using sctl and ./files/input.json in grid-router repo). - ## Contributing -1. Fork it; -2. Create your feature branch: `git checkout -b my-new-feature`; -3. Commit your changes: `git commit -am 'Add some feature'`; -4. Push to the branch: `git push origin my-new-feature`; -5. Submit a pull request. +1. Fork it +2. Create your feature branch: `git checkout -b my-new-feature` +3. Commit your changes: `git commit -am 'Add some feature'` +4. Push to the branch: `git push origin my-new-feature` +5. Submit a pull request ## License See LICENSE diff --git a/defaults/main.yml b/defaults/main.yml index dd2b61e..4099900 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,14 +1,14 @@ --- -selenoid_cm_version: 1.3.1 -selenoid_version: 1.4.0 -selenoid_docker_api_version: 1.24 -selenoid_limit: 4 -selenoid_tmpfs: 128 -selenoid_config_dir: /etc/selenoid -selenoid_listen_port: 4444 -selenoid_time_zone: Europe/Moscow -selenoid_browsers_last_versions: 5 -selenoid_browsers: +selenoid_version: 1.4.0 # Install selenoid version +selenoid_cm_version: 1.3.1 # Install configuration manager version +selenoid_docker_api_version: 1.24 # Docker api version (for Selenoid) +selenoid_limit: 4 # Total number of simultaneously running containers http://aerokube.com/selenoid/latest/#_recommended_docker_settings +selenoid_tmpfs: 128 # Add in-memory filesystem (tmpfs) to container http://aerokube.com/selenoid/latest/#_other_optional_fields +selenoid_config_dir: /etc/selenoid # Selenoid configuration dir +selenoid_listen_port: 4444 # Listen port +selenoid_time_zone: Europe/Moscow # Timezone in container +selenoid_browsers_last_versions: 5 # How many last version browsers need download in selenoid +selenoid_browsers: # What browsers to download - firefox - opera - chrome