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

Variable AST #5

Open
wied03 opened this issue Aug 20, 2016 · 0 comments
Open

Variable AST #5

wied03 opened this issue Aug 20, 2016 · 0 comments

Comments

@wied03
Copy link
Owner

wied03 commented Aug 20, 2016

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.

@wied03 wied03 changed the title Richer Overrides Variable Work Aug 21, 2016
@wied03 wied03 changed the title Variable Work Variable AST Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant