Skip to content

Commit

Permalink
improve format of jq filters (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallford authored Aug 12, 2024
1 parent 6ab7f13 commit b8a3be1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ data "ansible_navigator_run" "uptime_example" {
inventory = yamlencode({})
artifact_queries = {
"uptimes" = {
jq_filter = "[.plays[] | select(.name==\"Example\") | .tasks[] | select(.task==\"Gathering Facts\") | {host: .host, uptime_seconds: .res.ansible_facts.ansible_uptime_seconds }]"
jq_filter = <<-EOT
[.plays[] | select(.name=="Example") | .tasks[] | select(.task=="Gathering Facts") |
{host: .host, uptime_seconds: .res.ansible_facts.ansible_uptime_seconds }]
EOT
}
}
}
output "uptimes" {
value = jsondecode(data.ansible_navigator_run.uptime_example.artifact_queries.uptimes.results[0])
}
```

## Features
Expand Down
6 changes: 5 additions & 1 deletion docs/data-sources/navigator_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ data "ansible_navigator_run" "artifact_query_file" {
inventory = yamlencode({})
artifact_queries = {
"resolv_conf" = {
jq_filter = ".plays[] | select(.name==\"Example\") | .tasks[] | select(.task==\"Get file\") | .res.content"
jq_filter = <<-EOT
.plays[] | select(.name=="Example") |
.tasks[] | select(.task=="Get file") |
.res.content
EOT
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion examples/data-sources/ansible_navigator_run/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ data "ansible_navigator_run" "artifact_query_file" {
inventory = yamlencode({})
artifact_queries = {
"resolv_conf" = {
jq_filter = ".plays[] | select(.name==\"Example\") | .tasks[] | select(.task==\"Get file\") | .res.content"
jq_filter = <<-EOT
.plays[] | select(.name=="Example") |
.tasks[] | select(.task=="Get file") |
.res.content
EOT
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ resource "ansible_navigator_run" "test" {
jq_filter = ".stdout"
}
"file_contents" = {
jq_filter = ".plays[] | select(.name==\"Test\") | .tasks[] | select(.task==\"Get file\") | .res.content"
jq_filter = <<-EOT
.plays[] | select(.name=="Test") |
.tasks[] | select(.task=="Get file") |
.res.content
EOT
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ resource "ansible_navigator_run" "test" {
}
artifact_queries = {
"pull_args" = {
jq_filter = ".settings_entries.\"ansible-navigator\".\"execution-environment\".pull.arguments"
jq_filter = <<-EOT
.settings_entries."ansible-navigator"."execution-environment".pull.arguments
EOT
}
}
}
Expand Down

0 comments on commit b8a3be1

Please sign in to comment.