Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic check exist docker container selenoid #8

Merged
merged 5 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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