Skip to content

Variable AST #5

@wied03

Description

@wied03

Need to at least allow/parse return values from modules (see ec2_ami).

Could allow this:

task 'Copy something over' do
  result = foobar do
    src '/file1.conf'
    dest '/file2.conf'
  end

  become
  notify 'handler1'
  changed_when "'no upgrade' in #{result.stdout}"
end

to become this:

task 'Copy something over' do
  result = foobar do
    src '/file1.conf'
    dest '/file2.conf'
  end

  become
  notify 'handler1'
  changed_when result.stdout.include? 'no upgrade'
end

The first case already compiles to this:

---
# This is a generated YAML file by ansible-ruby, DO NOT EDIT
- name: Copy something over
  copy:
    src: "/file1.conf"
    dest: "/file2.conf"
  become: true
  register: result_1
  changed_when: "'no upgrade' in result_1.stdout"
  notify:
  - handler1

Basically it creates a light AST that would mimic the Ruby string/primitive methods and convert that to the Python/YAML/jinja stuff. Would want to cover basics only. More sophisticated stuff should be in custom modules. Even this might be difficult since different modules return different types of results.

Also could make the with_dict syntax easier so that you don't have to do value.stuff and instead can do value[:stuff]. Might be a slippery slope there though.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions