Skip to content

Commit

Permalink
Merge pull request #8 from iqoption/remove-container
Browse files Browse the repository at this point in the history
Add basic check exist docker container selenoid
  • Loading branch information
arslanbekov authored Jan 18, 2018
2 parents 25ff69e + 65f383b commit ab334a1
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[defaults]
roles_path = ../
hostfile = ./tests/inventory
21 changes: 13 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +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_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
13 changes: 13 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,5 +33,7 @@
--version {{ selenoid_version }}
--tmpfs {{ selenoid_tmpfs }}
--env DOCKER_API_VERSION={{ selenoid_docker_api_version }}
--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"
1 change: 1 addition & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost ansible_connection=local
1 change: 1 addition & 0 deletions tests/role.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost

0 comments on commit ab334a1

Please sign in to comment.