ansible role: Why do I have to set user.email in etckeeper?

sourcejedi

I wrote a ansible role to automate installing etckeeper.

I discover that git will complain if I haven't configured user.email. In some circumstances, git commits will fail. This includes automatic commits to etckeeper when installing a package, potentially causing the install to fail. So I have to add a task for that, like everyone else does :).

The frustrating thing is that in some circumstances, it seemed to work ok. And it doesn't seem to be a problem when using etckeeper manually. user.email is never mentioned in the tutorial.

Is it actually necessary to set user.email in the Ansible role? If so... there must be some deliberate reason(s) causing this. Some explanation, which I could put into a comment in the role, or which would justify a patch to etckeeper or git?

sourcejedi

UPDATE: should be fixed in the next release (1.18.8).

https://etckeeper.branchable.com/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/


After hitting this a couple of times, I felt I needed to look at the source code.

  1. git absolutely requires an "email address" for its commits. Without one, it will refuse to make a commit.
  2. git will "autodetect" an email, if the system hostname can be resolved to a Fully Qualified Domain Name. (You must have at least one . to qualify :). Or, if /etc/mailname exists, it uses that by preference, without checking for .s.
  3. etckeeper tries to pass an email address to git, constructed from a username and the system hostname. git will accept such explicitly-specified emails, even if the host part is not an FQDN. If sudo is used, etckeeper uses SUDO_USER from the environment. In case su is used, there is nothing in the environment, and so etckeeper reads the user from the owner of the tty.

So git commit and etckeeper vcs commit failed, when I hadn't set user.email, AND my hostname did not resolve to an FQDN.

etckeeper commit works in some situations that git commit doesn't. I believe I got confused between these two when I was testing before (among other things).

If you run etckeeper from sudo, it won't fail. If you run it from su, it won't fail. It won't fail either if you log in as root and run it; it will find a tty which is owned by root, and pass an email of root@HOSTNAME.

etckeeper commit will fail if and only if

  1. user.email is not set in git, AND
  2. the system hostname cannot be resolved to an FQDN, AND
  3. /etc/mailname does not exist (it is created by the Debian exim packages?) AND
  4. etckeeper is not run from sudo AND
  5. etckeeper is not run from a tty

Finally, testing indicated that commands run under ansible are never run from a tty. (Even when using an ssh connection and sudo with a password, where ansible is described as needing to use a pseudo-tty).

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Do I have to provide an email for a local user on Windows 10 Pro?

분류에서Dev

How do I set up an email server?

분류에서Dev

How do I get a variable with the name of the user running ansible?

분류에서Dev

Why do mount, ping and su have a sticky bit set?

분류에서Dev

Woocommerce email notifications additional recipients based on user role

분류에서Dev

Do I have to set all variables to private in C++ class?

분류에서Dev

Why do I have to set LD_LIBRARY_PATH before running a program, even though I already linked the library locations in the compile stage?

분류에서Dev

why do I have to pipe perl output into a new perl command

분류에서Dev

Why do I have low FPS unless root?

분류에서Dev

Why do I have to manually add Flex libraries in ActionScript Project

분류에서Dev

Why do i have to use a for loop and not a foreach loop?

분류에서Dev

Why do I have MBR and GPT as partition tables?

분류에서Dev

Git: why do I have to commit other people's changes

분류에서Dev

Why do I have two versions of gtk installed?

분류에서Dev

How do I set a default Chrome Person (user) to open URLs as?

분류에서Dev

How do I have a program in CLIPS assert user input without having the user type assert(whatever))

분류에서Dev

Why do I get a "MySQLSyntaxErrorException:Access denied for user:" error?

분류에서Dev

why do I have to declare an irrelevant struct file_handle variable before I can use that type?

분류에서Dev

How do I run Logstalgia if root login is disabled and ssh user doesn't have access to logs?

분류에서Dev

Why I have StackOverflow in DFS?

분류에서Dev

Why must a UNIX user have a password?

분류에서Dev

I want a user with "Administrators" role to see another line

분류에서Dev

Why does sudo -i not set XDG_RUNTIME_DIR for the target user?

분류에서Dev

Why does empty Bitbucket repo "contain work" that I "do not have locally"?

분류에서Dev

Why do I have two desktop.ini files on my windows 8 desktop?

분류에서Dev

Getting only value from PHP JSON array (why do I have to use implode?)

분류에서Dev

Why do I have to hit tab twice to Alt+Tab away from Microsoft Excel?

분류에서Dev

Why do I have to type .exe after all commands in windows 10?

분류에서Dev

Why do I have "join: extra operand '/dev/fd/62'" error?

Related 관련 기사

  1. 1

    Do I have to provide an email for a local user on Windows 10 Pro?

  2. 2

    How do I set up an email server?

  3. 3

    How do I get a variable with the name of the user running ansible?

  4. 4

    Why do mount, ping and su have a sticky bit set?

  5. 5

    Woocommerce email notifications additional recipients based on user role

  6. 6

    Do I have to set all variables to private in C++ class?

  7. 7

    Why do I have to set LD_LIBRARY_PATH before running a program, even though I already linked the library locations in the compile stage?

  8. 8

    why do I have to pipe perl output into a new perl command

  9. 9

    Why do I have low FPS unless root?

  10. 10

    Why do I have to manually add Flex libraries in ActionScript Project

  11. 11

    Why do i have to use a for loop and not a foreach loop?

  12. 12

    Why do I have MBR and GPT as partition tables?

  13. 13

    Git: why do I have to commit other people's changes

  14. 14

    Why do I have two versions of gtk installed?

  15. 15

    How do I set a default Chrome Person (user) to open URLs as?

  16. 16

    How do I have a program in CLIPS assert user input without having the user type assert(whatever))

  17. 17

    Why do I get a "MySQLSyntaxErrorException:Access denied for user:" error?

  18. 18

    why do I have to declare an irrelevant struct file_handle variable before I can use that type?

  19. 19

    How do I run Logstalgia if root login is disabled and ssh user doesn't have access to logs?

  20. 20

    Why I have StackOverflow in DFS?

  21. 21

    Why must a UNIX user have a password?

  22. 22

    I want a user with "Administrators" role to see another line

  23. 23

    Why does sudo -i not set XDG_RUNTIME_DIR for the target user?

  24. 24

    Why does empty Bitbucket repo "contain work" that I "do not have locally"?

  25. 25

    Why do I have two desktop.ini files on my windows 8 desktop?

  26. 26

    Getting only value from PHP JSON array (why do I have to use implode?)

  27. 27

    Why do I have to hit tab twice to Alt+Tab away from Microsoft Excel?

  28. 28

    Why do I have to type .exe after all commands in windows 10?

  29. 29

    Why do I have "join: extra operand '/dev/fd/62'" error?

뜨겁다태그

보관