Ansible 显示 rails 测试的输出

Ansible show output of rails tests

我有以下ansible play:

- name: run rails tests
  hosts: marflar
  sudo: yes
  sudo_user: vagrant
  tags:
    - rake
  tasks:
    - name: configure nokogiri
      command: bash -lc "bundle config build.nokogiri --use-system-libraries"

    - name: install gems
      command: bash -lc "bundle install"
      register: bundle_complete

    - name: check if database exists
      command: bash -lc "bundle exec rake db:version"
      ignore_errors: True
      register: rake_db_version_result

    - name: create database
      command: bash -lc "bundle exec rake db:setup"
      register: db_setup_complete
      when: rake_db_version_result|failed

    - name: apply database migrations
      command: bash -lc "bundle exec rake db:migrate"
      register: db_setup_complete
      when: rake_db_version_result|success

    - name: running the test suite
      command: bash -lc "bundle exec rake test"
      when: db_setup_complete

它运行良好,但在它完成之前我看不到 bundle exec rake test 的输出。有没有办法显示我的测试输出?

看起来像lot of people have requested this feature, but that the Ansible maintainers have decided that this kind of feature is not a good fit for the way Ansible is built


为清晰起见编辑:

不支持在ansible中提供实时输出的原因有很多,工单中有一些可靠的论据:

Ansible contains 235+ modules and the APIs used in basically all of these modules don't have any capacity for reporting status in the middle of an async operation

The CLI has no good way to output standard out changes when running in parallel against several hundred hosts

如果你真的想在命令执行时看到它的输出,你最好尝试 ssh 或其他一些工具,Ansible 不能这样做。