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

Simplfyed playbook #55

Merged
merged 11 commits into from
May 3, 2023
Merged

Simplfyed playbook #55

merged 11 commits into from
May 3, 2023

Conversation

umputun
Copy link
Owner

@umputun umputun commented May 3, 2023

The simplified playbook format offers an alternative to the full playbook and should be easier to read and write. This is not a replacement for the regular playbook; internally, it is converted to a full playbook with a single preset target "default" and a single task in the tasks list.

This is the format:

user: umputun                       
ssh_key: keys/id_rsa           
inventory: /etc/spot/inventory.yml  
target: ["devbox1", "devbox2", "h1.example.com:2222", "h2.example.com"] 

task:
  - name: wait
    script: sleep 5s
  
  - name: copy configuration
    copy: {"src": "testdata/conf.yml", "dst": "/tmp/conf.yml", "mkdir": true}
  
  - name: sync things
    sync: {"src": "testdata", "dst": "/tmp/things"}
  
  - name: some command
    script: |
      ls -laR /tmp
      du -hcs /srv
      cat /tmp/conf.yml
      echo all good, 123
  
  - name: delete things
    delete: {"path": "/tmp/things", "recur": true}
  
  - name: show content
    script: ls -laR /tmp

  - name: docker pull and start
    script: |
      docker pull umputun/remark42:latest
      docker stop remark42 || true
      docker rm remark42 || true
      docker run -d --name remark42 -p 8080:8080 umputun/remark42:latest
    env: {FOO: bar, BAR: qux} # set environment variables for the command
    
  - wait: {cmd: "curl -s localhost:8080/health", timeout: "10s", interval: "1s"} # wait for health check to pass

Main differences between the two types of playbooks:

  • The full playbook supports multiple target sets, while the simplified playbook supports only one target set. I.e. the full playbook can execute the same set of commands on multiple environments where each environment is defined as a separate target set. The simplified playbook can execute the same set of commands only in a single environment.
  • The full playbook supports multiple tasks, while the simplified playbook supports only one task. I.e. the full playbook can execute multiple sets of commands, while the simplified playbook can execute only one set of commands.
  • The full playbook support various targets type, i.e. hosts, groups, and names, while the simplified playbook supports only one type which is a list of names or host address.
  • Simplified playbook doesn't support task-level on_error, user, and ssh_key fields, while the full playbook does.

The rest of the fields and options are supported by both types of playbooks.

@umputun
Copy link
Owner Author

umputun commented May 3, 2023

this PR address #54

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4869308336

  • 141 of 157 (89.81%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 83.84%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/config/command.go 61 62 98.39%
app/config/playbook.go 57 64 89.06%
app/main.go 23 31 74.19%
Totals Coverage Status
Change from base Build 4865793665: 0.3%
Covered Lines: 1240
Relevant Lines: 1479

💛 - Coveralls

@umputun umputun merged commit f0069de into master May 3, 2023
@umputun umputun deleted the simple_playbook branch May 3, 2023 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants