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

Properly apt-get install inn2 in a GitHub Action. #310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Sep 14, 2024

Demonstrate how to properly apt-get install inn2 in a GitHub Action. Configure the inn2 instance so that other code can test interactions with the inn2 server.

Much of this project's documentation covers how to build inn2 from source. It would be helpful if there were working examples of how to properly apt-get install inn2 in Docker or in a GitHub Action. I have been struggling to do so for a few hours without success.

We probably need hostname=localhost and domain=localhost.localdomain but I have been unable to get it right.

Setting up inn2 (2.6.4-2build4) ...
innconfval: hostname does not resolve or domain not set in inn.conf
dpkg: error processing package inn2 (--configure):
installed inn2 package post-installation script subprocess returned error exit status 1

@Julien-Elie
Copy link
Contributor

Demonstrate how to properly apt-get install inn2 in a GitHub Action.

Couldn't the sample be provided as an example instead of being run at each push or pull request? Installing the inn2 package provided with stock Ubuntu (currently inn2-2.6.4-2build4) is not related to the push or pull request, so I don't think it is worthwhile running it. Of course I am OK to keep this example, either in contrib (like the sample init scripts) or in .github/workflows (deactivated).

We probably need hostname=localhost and domain=localhost.localdomain but I have been unable to get it right.

The last time I heard someone installing INN in Docker, the trick was to create the configuration file in /etc/news/inn.conf before installing the inn2 package. You can put domain: localhost.localdomain in the configuration file, and the Debian package will no longer fail to install.
A better way would be to use a custom preseed file but the current inn2 package does not implement it.

@cclauss
Copy link
Contributor Author

cclauss commented Sep 15, 2024

Thanks for this review. I agree that should be a contrib and we do not need this to run on each PR after we get it to work. I need help getting this action to work before we move it to contrib.

I will work on your suggestion above this evening.

@cclauss
Copy link
Contributor Author

cclauss commented Sep 15, 2024

Setting up inn2-inews (2.6.4-2build4) ...
Configuration file '/etc/news/inn.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
 ==> Keeping old config file as default.
[ ... ]
Setting up inn2 (2.6.4-2build4) ...
innconfval: must set mta in inn.conf
innconfval: must set pathnews in inn.conf
innconfval: must set hismethod in inn.conf
innconfval: ovmethod must be set in inn.conf if enableoverview is true
dpkg: error processing package inn2 (--configure):
 installed inn2 package post-installation script subprocess returned error exit status 1

@Julien-Elie
Copy link
Contributor

Julien-Elie commented Sep 15, 2024

It is a working inn.conf file that should be pre-installed (like the one the inn2 package installs), not an inn.conf file with only one line for the domain parameter.

@Julien-Elie
Copy link
Contributor

Alternately, maybe it would be easier to create an /etc/hostname file?

echo "localhost.localdomain" > /etc/hostname

Or whatever preferred value for your container.

INN uses the value returned by gethostname(3) or getaddrinfo(3) when domain is not set. I think the value in /etc/hostname will work.

@cclauss
Copy link
Contributor Author

cclauss commented Sep 15, 2024

OK... On my own repo https://github.com/cclauss/inn2-in-docker I am getting closer to a solution.

It works on a push on Ubuntu 22.04 but fails on 24.04. The same solution fails on a pull_request on this repo.
Edit: Simultaneously running two instances of inn2 fails, but separately both Ubuntu 22.04 and 24.04 work on a push.
Second edit: permissions: contents: write seems essential for pull_requests

In any case, where I could use help now is on the proof that inn2 is functioning properly. Things like:

  • Proof that the inn2 service is running: systemctl status inn2
  • Proof of which version of inn2 is running?
  • Short command to add a news article to the inn2 service?
  • Short command to read back that news article?

  • Ubuntu 22.04: Setting up inn2-inews (2.6.4-2build4)
  • Ubuntu 24.04: Setting up inn2-inews (2.7.2~20240212-1build3)

@Julien-Elie
Copy link
Contributor

Oh, great news you managed to make it work!
If you want to run two instances of INN on the same server, you should use different ports for innd (119 and 433 for instance), and naturally different installation directories (they cannot use the same active file, news spool, etc.).

% innconfval version 
INN 2.8.0 (20240722 prerelease)
% innconfval pathdb       
/home/news/db

For commands to test the installation, including posting articles, you may want to see the autopkgtest script Marco wrote for the inn2 Debian package.
If you prefer Python, you could use nntplib which provide similar facilities.

Otherwise, using inews to post an article, and sm to retrieve it would work.

@cclauss cclauss force-pushed the patch-1 branch 2 times, most recently from 2246419 to fc84600 Compare September 16, 2024 18:27
Demonstrate how to properly `apt-get install inn2` in a GitHub Action.
Configure the inn2 instance so that other code can test interactions with the inn2 server.

Much of this project's documentation covers how to build inn2 from source.  It would be helpful if there were working examples of how to `apt-get install inn2` in Docker or in a GitHub Action.  I have been struggling to do so for a few hours without success.
@cclauss
Copy link
Contributor Author

cclauss commented Sep 17, 2024

OK. The GitHub Action works as I wished... On push, pull_request, and workflow_dispatch the Action does:

  1. apt-get install inn2 # Almost always works.
  2. systemctl status inn2
  3. Used Python <= v3.12 nntplib to run various interactions including posting and reading back an article.

I will move that all into the contrib directory if you agree.


Now, I would like to use the lessons learned to create a Docker image but without an inn.conf file apt-get install inn2 fails if hostname returns buildkitsandbox instead of localhost.localdomain.

At build-time in both Debian and Ubuntu containers, hostname returns buildkitsandbox. Would it be possible to modify the apt-get install inn2 script to convert buildkitsandbox to localhost.localdomain?

At Docker build-time, it has proven quite tricky to change the output of hostname.

Dockerfile:

FROM debian:bookworm
# FROM ubuntu:24.04
# `hostname` at Docker built time returns 'buildkitsandbox' on both Debian and Ubuntu
ENV DEBIAN_FRONTEND=noninteractive
RUN hostname
CMD ["exit"]

% docker build --no-cache --progress plain .

@Julien-Elie
Copy link
Contributor

Hi Christian! Thanks for your work.

What are the reasons for the failure of apt-get install inn2? Is it something we have a hand on, or a transient failure of GitHub Actions?

nntplib is now an externally maintained library here: https://git.cepl.eu/cgit/python/nntplib
It is unfortunately not in PyPi 😞. I hope it will be there again (it had been for a few months but somehow disappeared).

Yes, I agree the sample GitHub Actions could go to contrib. Another possibility would be to keep it there, but deactivated (there may be a command to say so, or suffix it with a .sample extension). Also, the test article file could go to tests/data/articles/github-action-1; I think it would be better there (with possible another filename you think more appropriate).

@Julien-Elie
Copy link
Contributor

At build-time in both Debian and Ubuntu containers, hostname returns buildkitsandbox. Would it be possible to modify the apt-get install inn2 script to convert buildkitsandbox to localhost.localdomain?

You should ask the Debian maintainer via opening an inn2 bug for this feature. A custom preseed file could for instance be implemented for setting domain in inn.conf.

@cclauss
Copy link
Contributor Author

cclauss commented Sep 18, 2024

nntplib is now an externally maintained library here: https://git.cepl.eu/cgit/python/nntplib
It is unfortunately not in PyPi 😞. I hope it will be there again (it had been for a few months but somehow disappeared).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants