{"id":19044522,"url":"https://github.com/stdevel/demo-formula","last_synced_at":"2025-10-25T19:14:01.575Z","repository":{"id":79816746,"uuid":"350731617","full_name":"stdevel/demo-formula","owner":"stdevel","description":"Test-driven development example for Salt Formulas","archived":false,"fork":false,"pushed_at":"2021-05-11T08:39:12.000Z","size":40,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-21T23:22:07.974Z","etag":null,"topics":["salt","saltstack","saltstack-formula","suse-manager","uyuni"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stdevel.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2021-03-23T13:54:31.000Z","updated_at":"2021-05-11T08:38:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"492cf8bb-7acd-497f-9561-7cfe4e2773c5","html_url":"https://github.com/stdevel/demo-formula","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stdevel/demo-formula","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdevel%2Fdemo-formula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdevel%2Fdemo-formula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdevel%2Fdemo-formula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdevel%2Fdemo-formula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stdevel","download_url":"https://codeload.github.com/stdevel/demo-formula/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stdevel%2Fdemo-formula/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278315198,"owners_count":25966775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["salt","saltstack","saltstack-formula","suse-manager","uyuni"],"created_at":"2024-11-08T22:46:32.616Z","updated_at":"2025-10-04T12:51:30.389Z","avatar_url":"https://github.com/stdevel.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# demo-formula\n\nSimple Salt formula for demonstrating test-driven development for SUSE Manager\n\n## Usage\n\nThis formula simply sets the content of `/etc/motd` to the output of a particular `cowsay` output. It supports changing the text and cow type via **Pillar**:\n\n- `motd.cow_type` - cow type, see man page (*default: `-s`*)\n- `motd.text` - message (*default: 'SUSECON 21'*)\n\n## Testing via `kitchen`\n\nYou can use [test-kitchen](https://github.com/test-kitchen/test-kitchen) to automate development and testing:\n\n- Create instances locally or in the cloud (*VM, container*)\n- Running Salt code\n- Verifying acceptance criteria (*e.g. using [InSpec](https://inspec.io)*)\n\ntest-kitchen can be installed using `gem`:\n\n```shell\n# gem install kitchen kitchen-inspec kitchen-docker\n```\n\nIf you want to use [Vagrant](https://vagrantup.com) machines instead of containers, you'll need to install Vagrant and the [`kitchen-vagrant`](https://rubygems.org/gems/kitchen-vagrant) package as well.\n\nThis repository's [kitchen configuration](kitchen.yml) uses Docker containers - check-out the commented out lines if you want to use virtual machines instead.\n\nThe first step is to create the instance, in this case openSUSE Leap 15.2 is used.\n\n```shell\n$ kitchen create\n-----\u003e Creating \u003cdefault-opensuse-leap-152-master-py3\u003e...\n       Sending build context to Docker daemon  357.4kB\n       Step 1/15 : FROM saltimages/salt-master-py3:opensuse-leap-15.2\n...\n-----\u003e Test Kitchen is finished. (0m45.26s)\n```\n\nAfterwards you should be able to list the instance:\n\n```shell\n$ kitchen list\nInstance                              Driver  Provisioner  Verifier  Transport  Last Action  Last Error\ndefault-opensuse-leap-152-master-py3  Docker  SaltSolo     Inspec    Ssh        Created\n```\n\nNow run the Salt code:\n\n```shell\n$ kitchen converge\n-----\u003e Starting Test Kitchen (v2.7.2)\n-----\u003e Converging \u003cdefault-opensuse-leap-152-master-py3\u003e...\n...\n       Summary for local\n       ------------\n       Succeeded: 2 (changed=2)\n       Failed:    0\n       ------------\n       Total states run:     2\n       Total run time:  33.796 s\n       Downloading files from \u003cdefault-opensuse-leap-152-master-py3\u003e\n       Finished converging \u003cdefault-opensuse-leap-152-master-py3\u003e (0m43.28s).\n```\n\nNote that **2 changes** have been made. The next step is to run the unit tests:\n\n```shell\n$ kitchen verify\n...\n  ✔  demo-01: Package cowsay installed\n     ✔  System Package cowsay is expected to be installed\n  ✔  demo-02: /etc/motd updated\n     ✔  File /etc/motd is expected to exist\n     ✔  File /etc/motd content is expected not to == \"\"\n\n\nProfile Summary: 2 successful controls, 0 control failures, 0 controls skipped\nTest Summary: 3 successful, 0 failures, 0 skipped\n```\n\nThe [acceptance criteria tests](test/demo_tests.rb) have passed.\n\nAs the testing is now completed you can remove the instance:\n\n```shell\n$ kitchen destroy\n-----\u003e Destroying \u003cdefault-opensuse-leap-152-master-py3\u003e...\n...\n-----\u003e Test Kitchen is finished. (0m2.78s)\n```\n\n## Using in SUSE Manager\n\nCreate state and metadata folders for the formula (`demo`):\n\n```shell\n# mkdir /usr/share/susemanager/formulas/{metadata,states}/demo\n```\n\nCopy metadata information and states:\n\n```shell\n# cp metadata/* /usr/share/susemanager/formulas/metadata/demo/\n# cp demo/init.sls /usr/share/susemanager/formulas/states/demo/\n```\n\nYou will now find a new Salt Formula when configuring hosts. Enable it, click \"*Save*\" and you will see a new pane where you can set Pillar information:\n\n![uyuni_formula.png](uyuni_formula.png)\n\nTry applying the high state and login to the system via SSH - you should see a new login message:\n\n```shell\n$ ssh giertz@pinkepank\n...\n ____________ \n\u003c SUSECON 21 \u003e\n ------------ \n        \\   ^__^\n         \\  (**)\\_______\n            (__)\\       )\\/\\\n             U  ||----w |\n                ||     ||\n```\n\n## Building a RPM package\n\nAn easier way of distribution is to ship RPM packages.\nYou will need an openSUSE or SLES machine and install some development packages:\n\n```shell\n# zypper in -y tar gzip rpmdevtools rpm-build git\n```\n\nIf not already done, clone this git repository. Also, rename the folder and create a tarball for the specific version:\n\n```shell\n$ git clone https://github.com/stdevel/demo-formula.git\n$ mv demo-formula demo-formula-1.0\n$ mkdir -p ~/rpmbuild/SOURCES\n$ tar cvfz ~/rpmbuild/SOURCES/demo-formula-1.0.tar.gz demo-formula-1.0\n```\n\nNow create release and source RPM packages:\n\n```shell\n$ rpmbuild -ba demo-formula-1.0/demo-formula.spec\n```\n\nIn the `rpmbuild/RPMS` folder you will find a RPM package that can be installed easily on SUSE Manager or Uyuni.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstdevel%2Fdemo-formula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstdevel%2Fdemo-formula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstdevel%2Fdemo-formula/lists"}