volanja / ansible-sample-tdd Goto Github PK
View Code? Open in Web Editor NEWTest Driven Development for Ansible by ServerSpec. It's Sample
Test Driven Development for Ansible by ServerSpec. It's Sample
I have host file like this:
[group1]
x.x.x.x
x.x.x.x
[group2]
x.x.x.x
x.x.x.x
[group2]
x.x.x.x
x.x.x.x
[group3]
x.x.x.x
x.x.x.x
[group4]
x.x.x.x
x.x.x.x
And now you only can run tests with all nodes or only with a group with hosts: parameter in playbook.
- name: Ansible-Sample-TDD
hosts: [server/all]
user: root
vars:
worker_connections: 8192
roles:
- nginx
- mariadb
Is possible run a test in more than one but not in all groups?
Could you update your structure to match the Anible roles? It could serve as a template.
I currently use static inventories with the following structure in ansible:
enviro/dev/hosts
enviro/staging/hosts
enviro/live/hosts
Any idea on how should I play around .ansiblespec
in order to be able to run rake -T staging
or rake -T dev
?
I want to run differente test for differente host
[ubuntu]
172.23.10.22 ansible_ssh_host=172.23.10.22 ansible_ssh_user=test ansible_ssh_pass=test
[centos]
172.23.10.23 ansible_ssh_host=172.23.10.23 ansible_ssh_user=test ansible_ssh_pass=test
[other]
172.23.10.24 ansible_ssh_host=172.23.10.24 ansible_ssh_user=test ansible_ssh_pass=test
[pg]
ubuntu
centos
[mail]
other
ubuntu
centos
my site.yml
I want rake:pg run in ubuntu and centos hosts and rake:mail run in all hosts.
Therefore I need spec for centos are differents of test for ubuntu. It is possible? How?
Hello,
I'm using kitchen-test with serverspec and my directory tree for spec files is
roles/myrole/test/integration/(default|somethingelse)/serverspec
If I do a symlink as roles/myroles/spec, ansiblespec is working fine.
is it possible to add a configuration option to specfiles: test/integration/default/serverspec/*_spec.rb ?
Thanks
Hello,
With a quick test of one of my playbook, I have one working and one not.
it seems ansiblespec is not covering roles of the second group inside the playbook.
$ grep -A3 roles vpn.yml
roles:
- openvpn-restorekeys
- Stouts.openvpn
tasks:
--
roles:
- openvpnclient
tasks:
- set_fact:
$ rake -T
rake all # Run serverspec to all test
rake serverspec:Ansible-vpn-satellite # Run serverspec for Ansible-vpn-satellite
rake serverspec:Ansible-vpnserver # Run serverspec for Ansible-vpnserver
$ rake serverspec:Ansible-vpnserver --trace
** Invoke serverspec:Ansible-vpnserver (first_time)
** Execute serverspec:Ansible-vpnserver
Run serverspec for Ansible-vpnserver to {"name"=>"HOST1 ansible_ssh_host=x.y.z.202 ansible_ssh_user=root ansible_sudo=true ansible_ssh_private_key_file=/home/user/.ssh/keys/id_rsa ansible_ssh_port=22", "port"=>22, "uri"=>"x.y.z.202", "user"=>"root", "private_key"=>"/home/user/.ssh/keys/id_rsa"}
/home/user/.rvm/rubies/ruby-2.3.0/bin/ruby -I/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-support-3.5.0/lib:/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/lib /home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/exe/rspec --pattern roles/\{openvpn-restorekeys,Stouts.openvpn\}/spec/\*_spec.rb
Service "openvpn"
should be enabled
File "/usr/sbin/openvpn"
should be executable
Finished in 0.06718 seconds (files took 0.21904 seconds to load)
2 examples, 0 failures
Run serverspec for Ansible-vpnserver to {"name"=>"HOST2 ansible_ssh_host=x.y.z.242 ansible_ssh_port=22 ansible_ssh_private_key_file=/home/user/.ssh/keys/id_rsa", "port"=>22, "uri"=>"x.y.z.242", "private_key"=>"/home/user/.ssh/keys/id_rsa"}
/home/user/.rvm/rubies/ruby-2.3.0/bin/ruby -I/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-support-3.5.0/lib:/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/lib /home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/exe/rspec --pattern roles/\{openvpn-restorekeys,Stouts.openvpn\}/spec/\*_spec.rb
Service "openvpn"
should be enabled
File "/usr/sbin/openvpn"
should be executable
Finished in 0.05259 seconds (files took 0.21698 seconds to load)
2 examples, 0 failures
$ rake serverspec:Ansible-vpn-satellite --trace
** Invoke serverspec:Ansible-vpn-satellite (first_time)
** Execute serverspec:Ansible-vpn-satellite
Run serverspec for Ansible-vpn-satellite to {"name"=>"HOST3 ansible_ssh_host=x.y.z.102 ansible_user=deploy ansible_become=true ansible_ssh_private_key_file=/home/user/.ssh/keys/id_rsa", "port"=>22, "uri"=>"x.y.z.102", "private_key"=>"/home/user/.ssh/keys/id_rsa"}
rake aborted!
NoMethodError: undefined method `map' for nil:NilClass
Did you mean? tap
/home/user/.rvm/gems/ruby-2.3.0/gems/ansible_spec-0.2.15/lib/ansible_spec/load_ansible.rb:206:in `load_dependencies'
/opt/tmp/vagrant/homelab/Rakefile:36:in `block (5 levels) in <top (required)>'
/opt/tmp/vagrant/homelab/Rakefile:35:in `each'
/opt/tmp/vagrant/homelab/Rakefile:35:in `block (4 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/lib/rspec/core/rake_task.rb:95:in `block (2 levels) in define'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/file_utils_ext.rb:58:in `verbose'
/home/user/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.2/lib/rspec/core/rake_task.rb:94:in `block in define'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/user/.rvm/gems/ruby-2.3.0@global/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/user/.rvm/rubies/ruby-2.3.0/bin/rake:23:in `load'
/home/user/.rvm/rubies/ruby-2.3.0/bin/rake:23:in `<main>'
Tasks: TOP => serverspec:Ansible-vpn-satellite
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.