{"id":15508687,"url":"https://github.com/jay7x/puppetbolt-pty","last_synced_at":"2026-02-14T19:03:06.336Z","repository":{"id":253663521,"uuid":"844160576","full_name":"jay7x/puppetbolt-pty","owner":"jay7x","description":"Puppet Bolt module to interact with a process spawned via PTY","archived":false,"fork":false,"pushed_at":"2025-01-04T08:40:30.000Z","size":35,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T20:42:09.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jay7x.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-18T15:09:50.000Z","updated_at":"2025-01-04T08:40:30.000Z","dependencies_parsed_at":"2025-04-23T02:34:03.769Z","dependency_job_id":"875b87bc-360a-49a8-a256-fbb06fdc0f1b","html_url":"https://github.com/jay7x/puppetbolt-pty","commit_stats":null,"previous_names":["jay7x/puppet-pty"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jay7x/puppetbolt-pty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay7x%2Fpuppetbolt-pty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay7x%2Fpuppetbolt-pty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay7x%2Fpuppetbolt-pty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay7x%2Fpuppetbolt-pty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jay7x","download_url":"https://codeload.github.com/jay7x/puppetbolt-pty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay7x%2Fpuppetbolt-pty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29452593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T09:39:41.614Z","updated_at":"2026-02-14T19:03:06.317Z","avatar_url":"https://github.com/jay7x.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `pty` Puppet Bolt module\n\n## Table of Contents\n\n1. [Description](#description)\n1. [Usage](#usage)\n1. [Reference](#reference)\n\n## Description\n\nThe module provides resources to spawn a command on a PTY and to interact with\nit from Puppet DSL.\n\n## Usage\n\nUse `pty::spawn()` function in a Bolt plan to spawn a command on a newly\nallocated PTY. In a block form, this function yields a PTY::IO object as a\nblock parameter. When the function has no block, it'll return a PTY::IO object.\nUse the PTY::IO object to interact with the process spawned.\n\n### Example 1. Talk to /bin/sh locally\n\n```puppet\n  $pty = pty::spawn(['/bin/sh', '--norc'])\n  # Enable debug messages on stderr\n  $pty.set_debug(true)\n  # Switch PTY to raw mode\n  $pty.set_raw()\n\n  # Change PS1 prompt to something we know\n  $pty.puts('export PS1=\"pty::io$ \"')\n  # Read reply and throw it away (wait 0.5 second for more input if any)\n  $pty.read(timeout =\u003e 0.5)\n\n  # Set the prompt to be expected by `pwp()` and `pwp_until()` methods\n  $pty.set_expected_prompt(/\\Rpty::io\\$ /)\n\n  # Send `hostname` command, get reply and strip any whitespace including\n  # terminating '\\n'\n  $hostname = $pty.pwp('hostname').strip()\n  out::verbose($hostname)\n\n  # Type '# Hello world'\n  out::verbose($pty.type_in('# Hello world'))\n\n  # Print current unix time and check if last digit is 0. Repeat 11 times if\n  # not, waiting 1 sec before next iteration. Return unix time matching.\n  $time = $pty.pwp_until('date +\"%s\"', /0$/, { interval =\u003e 1, limit =\u003e 11 }).strip()\n  out::verbose($time)\n\n  # Close IO streams and kill the process\n  $pty.close()\n```\n\n### Example 2. Configure remote iDRAC via SSH\n\n**WARNING:** Do not execute this code in your environment until you clearly\nunderstand what it does. The module authors takes no responsibility for any\ndamage, loss, or injury resulting from the use or inability to use this example\ncode. By using this example code, you acknowledge that you do so at your own\nrisk!\n\n```puppet\n  $targets.get_targets.parallelize |$t| {\n    pty::spawn(['/usr/bin/ssh', $t.vars.get('bmc_host')]) |$bmc| {\n      $bmc.set_raw()\n      $bmc.expect(/^(\\/[^\u003e]+\u003e|racadm\u003e\u003e)/, timeout =\u003e 60) # Wait for prompt\n      $bmc.set_expected_prompt(/\\Rracadm\u003e\u003e/)\n      $bmc.pwp('racadm') # Not needed on newer iDRAC but does no real harm\n\n      # Use HTML5 VirtualConsole\n      $bmc.pwp('set iDRAC.VirtualConsole.PluginType HTML5')\n\n      ## BIOS setup\n      # Disable HyperThreading\n      $bmc.pwp('set BIOS.ProcSettings.LogicalProc Disabled')\n      # Use PerfOptimized system profile\n      $bmc.pwp('set BIOS.SysProfileSettings.SysProfile PerfOptimized')\n\n      # Create job to setup BIOS on reboot\n      $bios_setup_jid = $bmc.pwp('jobqueue create BIOS.Setup.1-1') ? {\n        /^Commit JID = JID_(\\d+)$/ =\u003e \"JID_${1}\",\n        default =\u003e fail('Cannot create BIOS.Setup.1-1 job'),\n      }\n\n      if $reboot {\n        $bmc.pwp('serveraction powercycle')\n\n        # Check the job status until regex matches or timeout happens.\n        # Do 20 tries, sleeping 15 sec before next try.\n        $bmc.pwp_until(\"jobqueue view -i ${bios_setup_jid}\", /^Message=\\[PR19:/, interval =\u003e 15, limit =\u003e 20).lest || {\n          fail(\"Job ${bios_setup_jid} doesn't succeed in time\")\n        }\n      }\n    }\n  }\n```\n\n## Reference\n\nFor detailed information on functions and types, see [REFERENCE.md](https://github.com/jay7x/puppetbolt-pty/blob/main/REFERENCE.md).\n\n## License\n\nSee the LICENSE file in this repository for terms and conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay7x%2Fpuppetbolt-pty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjay7x%2Fpuppetbolt-pty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay7x%2Fpuppetbolt-pty/lists"}