Nope. Ansible uses sudo to elevate privileges on Linux. If you don't have a 
service account that can sudo, you can't do this with ansible. Your service 
account is the "remote_user" that ansible uses to SSH into the machine. The 
sudoers file must grant this account sudo rights.

It does not have to be passwordless sudo. You can provide a variable 
ansible_become_password that contains the sudo password. There are many ways to 
do that. The most secure way would be an ansible vault. This is essentially an 
encrypted vars file. You provide the vault secret when you run the playbook. On 
your command line you would do something like this.

$ ansible-playbook my_playbook.yml -e @my_vault.yml --ask-vault-pass

The @my_vault.yml tells ansible-playbook to source the my_vault.yml for its 
extra_vars. The --ask-vault-pass prompts you for the vault secret. Your 
my_vault.yml file would look like this:

---
ansible_become_password: "my sudo password"

If you use Ansible Tower you can provide the vault secret in an Ansible Vault 
Credential type. We use this method also for storing privileged Kerberos 
credentials that enables our playbooks to join machines to Active Directory.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 1, 2022, at 1:15 AM, dulhaver via Ansible Project 
<ansible-project@googlegroups.com<mailto:ansible-project@googlegroups.com>> 
wrote:

I need to create a postgresql@[db_service_name].service for systemd on remote 
hosts. Based on extremely limited access rights on such hosts (due to strict 
company security policies) the challenge I am facing is that the only way to do 
this manually is via

  sudo systemctl edit --full postgresql@[db_service_name].service

This allows to edit a unitfile interactively which then is used to start the 
service.
I do not have any direct write access to /etc/systemd/system or anything else 
outside /opt on such remotes.

so, is there any way to get specific values into that unit file via ansible 
under such circumstances?

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com<http://2Fgroups.google.com>%2Fd%2Fmsgid%2Fansible-project%2F1823518936.133081.1662009342899%2540office.mailbox.org<http://2540office.mailbox.org>&amp;data=05%7C01%7Cwalter.rowe%40nist.gov<http://40nist.gov>%7C2c0b8a00151445d73e4508da8bd908fd%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637976061533248124%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=XpM%2B9O9POGhoWj9dE9%2Bk%2Bc9Ub0TercGjG2e1oIXZBKo%3D&amp;reserved=0.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/F19F89B1-6C1B-4F50-B2AF-8681D60E408E%40nist.gov.

Reply via email to