327 plugins

Home

Examples

Plugins

Components

News

Sparrow usage examples

  • Git
  • CICD
  • Systemd
  • Podman
  • Kubernetes
  • Azure
  • Aws
  • Linters
  • Raku
  • Alpine
  • Utils

Set up Git repository

task-run "set git", "git-base", %(
  :email<melezhik@gmail.com>,
  :name<Alexey Melezhik>,
  :config_scope<local>,
  :set_credential_cache<on>
);

List total commits by author (sorted by commit count)
my %state = task-run "git stat", "git-commits-by-author";

for %state<list><> -> $i {
  say "author: ",$i<author>, 
      "commits: ", $i<commits>, 
      "email: ", $i<email>;
}

Queue Azure DevOps build and wait till it finishes

my %state = task_run "run my build", "ado-pipeline-build", %(
  name => "WebApp",
  variables => "foo:1 bar:2"
  action => "run"
);

# wait till the my  build finishes
task_run "wait my build", "ado-pipeline-build", %(
  action => "wait",
  build_id => %state<build_id>
);

Run GitLab Pipeline
task-run "pipe-run", "gitlab-run-pipeline", %(
  :debug,
  :1001project,
  :gitlab_api<https://git.company.com/api/v4/>,
  variables => %(
    :color<green>,
    :size<big>,
    :dev_mode
  )
)

Installs systemd unit for service

my $s = task-run "container deploy service", "systemd-service-unit", %(
  :description<container-deploy>,
  :name<container-deploy>,
  :type<oneshot>,
  environment => ["HOME=/root", "GOCACHE=/tmp/go-cache", "GOPATH=/tmp/go"],
  :environment_file</etc/default/container-deploy>,
  exec_start => "/usr/bin/go run /usr/local/bin/container-deploy.go",
);

if $s {
  bash "systemctl daemon-reload";
}

Install systemd unit for timer
my $s = task-run "my timer", "systemd-timer-unit",  %(
  :description<Container Deploy Timer>,
  :name<container-deploy>,
  :requires<container-deploy.service>,
  :on_boot_sec<5min>,
  :on_unit_active_sec<3min>,
  :randomized_delay_sec<1min>,
  :accuracy_sec<2min>,
);

if $s {
  bash "systemctl daemon-reload";
  service-enable "container-deploy.timer";
}

Create simple sleep service, using quadlet generator

my $s = task-run "sleep service", "quadlet-resource", %(
  :type<container>,
  :!templated,
  :description<my sleep>,
  :name<mysleep>,
  :containername<mysleep>,
  :hostname(""),
  :image<registry.access.redhat.com/ubi9-minimal:latest>,
  :exec<sleep 1000>,
);

if $s {
  bash "systemctl daemon-reload";
  service-start "mysleep";
}

Deploy new version of container based on container template
my $s = task-run "app deploy", "quadlet-container-deploy", %(
  :name<my-app>,
  :version<feature-foo>,
);

bash "systemctl daemon-reload";

service-start "my-app\@feature-foo";

Test if a k8s deployment exists and has attributes

task-run "dpl check", "k8s-deployment-check" %(
  name => "animals",
  namespace => "pets",
  cat => %(
    command => "/usr/bin/cat",
    args => [
      "eat", "milk", "fish" 
    ],
    env => [
      "ENABLE_LOGGING"
    ]
    volume-mounts => {
      foo-bar => "/opt/foo/bar",
    }
  )
);

Test if k8s config map exists and has entries
task-run "cm check", "k8s-config-check", %(
  type => "configmap",
  name => "web-config",
  namespace => "dashboards",
  # check if we have admin and password entries 
  # in config map
  data => [
    "note: creds for login",
    "[admin=root]",
    'regexp: "[password=" \S+ "]" $$',
  ]
);

Check that Azure KV secrets exists

task-run "check secrets", "azure-kv-secrets-check", %(
  name => "kv100", # the name of keyvault
  exists => [ # these keys should exists
    'password1',
    'password2',
    'db-password1',
    'db-password2'
  ]
)

Calculate permission number for Azure Devops permissions
task-run "permissions sum", "ado-permissions-calculator", %(
  namespace => "Library",
  actions => ["View", "Create"]
);

Create ec2 instance

task-run "create ec2", "aws-ec2", %(
  :action<create>,
  :name<node0>,
  :image<ami-0e322da50e0e90e21>,
  :type<t2.micro>,
  :subnet_id<foobarbaz>,
);

Show ec2 instance info in human readable format
s6 --plg-run aws-show-instance@id=bla_bla_bla

Lint yaml files

task-run "yaml lint", "yaml-lint", %(
  :files<*.yaml>,
  :!use_python,
);

Lint jinja templates
task-run "jinja lint", "jinjalint", %(
  args => [
    "template-directory/*.j2",
  ]
)

Install Azure cli

s6 --plg-run alpine-az-cli-install

Validate APKBUILD file
s6 --plg-run apkbuild-strict@path=community/raku-sparrow6/APKBUILD

Set up fez account

s6 --plg-run fez-login@user=melezhik,password=superSECRET123

Fetch zef distribution and return download directory
my %state = task-run "zef fetch Kind", "zef-fetch", %(
  identity => 'Kind'
);

say %state<directory>

Install Rakudo
task-run "install Rakudo 2025.08", "rakudo-install", %(
  version => "2025.08",
  user => "alex",
);

Setup nanorc file

s6 --plg-run nano-setup

Verify that disks are full on no more than 70 percents
s6 --plg-run df-check@threshold=70