[RUBY] Your ansible and serverspec combination is wrong!

Your wrong use

The motive for using it together is wrong in the first place

There is a person who uses it together with the motive of "I'm worried whether the ansible code is correct, so check it with serverspec", but it is a mistake. It is impossible to check unless the serverspec code is absolutely correct.

Check the same result with ansible and serverspec

with ansible

python


- name: restart hogehoge.service
  systemd:
    name: hogehoge.service
    state: restarted
    daemon_reload: yes
    enabled: yes
  become: yes

With serverspec,

describe process('hogehoge') do
  it { should be_running }
end

It is also a mistake to write ** only **.

Since the systemd module is guaranteed idempotent, it makes no sense to check the serverspec for process startup. If you know TDD's "test your anxiety" word, let's suppress the meaning of idempotence.

If you really want to check with serverspec, you should check the value of the configuration file referenced by the service other than starting the process. However, keep in mind that all those check items can be confirmed with ansible.

Recommended Posts

Your ansible and serverspec combination is wrong!
Metaclass and is instance
Python3, venv and Ansible