The Wizard: Side effects

- 7 mins

He has questions.

Nevertheless, he has not yet arrived. And you know you have answers. You interrupt your summoning, and sit down. You can continue in another moment. Everything happens for a reason. You just hope the reason is good.

N appears right next to you.

He has progressed immensely since the last time you saw him. People are starting to ask him for help now. You can’t help but feel pride when you see what he has become.

Interesting. He did realize after all.

That’s good stuff, you think.

He realized the hard way. That is probably a good thing. It is the best way to learn.

You summon the enclosure you both worked on on that occasion. You need it in order to properly analyze the spell. You check the structure of it:

# tasks/main.yml
---

- name: Install epel-release
  yum:
    name: epel-release
    state: present

- name: Install nginx
  yum:
    name: nginx
    state: present
  notify: Start nginx

It all comes back to you. You remember noticing the little issue with this proposal. It was a time bomb. But then again, he found it. It’s precisely what you wanted.

Patience is key.

He considers the idea for half a second.

You reflect for a second, structuring your thoughts, trying to imagine exactly what you need. You analyze the dimensions of the enclosure. Depth, width and height. It won’t suffice for what you have in mind. Once you figure it out, you close your eyes, and expand the enclosure in order to create a new dimension, invisible to the naked eye. Inside this new pocket within time and space, you place the side effect of the spell, just as he described it:

# molecule/default/side_effect.yml
---

- name: Stop nginx
  hosts: all
  tasks:
    - name: Stop nginx
      service:
        name: nginx
        state: stopped

This will probably suffice, you say to yourself.

You concentrate as you modify the structure and logic of the enclosure in order to use the new dimension:

# molecule/default/molecule.yml
scenario:
  name: default
  test_sequence:
    - destroy
    - syntax
    - lint
    - create
    - converge
    - side_effect
    - converge
    - idempotence
    - verify

N claps his hands, and as he separates them, a stream of bright red light appears between them:

    =================================== FAILURES ===================================
    __________________ test_nginx_is_running[ansible://instance] ___________________

    host = <testinfra.host.Host object at 0x108390290>

        def test_nginx_is_running(host):
            # Given
            nginx = host.service('nginx')
            # Then
    >       assert nginx.is_running
    E       assert False
    E        +  where False = <service nginx>.is_running

    tests/test_default.py:20: AssertionError

He looks stunned for a while.

N modifies the spell structure.

# tasks/main.yml
---
# tasks file for nginx-tdd

- name: Install epel-release
  yum:
    name: epel-release
    state: present

- name: Install nginx
  yum:
    name: nginx
    state: present

- name: Start nginx
  service:
    name: nginx
    state: started
    enabled: true

It looks good.

N does exactly the same thing he did before. Only this time, bright green light emanates from his palms:

    ============================= test session starts ==============================
    platform darwin -- Python 2.7.11, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
    rootdir: /Users/sebiwi/stuff/ocac/skool-ops/craftmanship-ops/ansible-tdd/ansible-nginx-tdd/molecule/default, inifile:
    plugins: testinfra-1.7.1
collected 3 items

    tests/test_default.py ...                                                [100%]

    =========================== 3 passed in 7.78 seconds ===========================
Verifier completed successfully.

N looks at you.

He is right. But he needs to see the bigger picture.

He reflects. He’s starting to get it.

Your attention already shifted back to your summoning. What now?

You’re no longer there again. N looks around in confusion.

Sebiwi

Sebiwi

Perfectionist

comments powered by Disqus
rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora