can't start service on systemd with ampersand (openvpn@server)

1,692 views
Skip to first unread message

senorsmile

unread,
Dec 23, 2013, 3:48:46 PM12/23/13
to ansible...@googlegroups.com
I'm trying to control openvpn on an arch linux server.  

I am able to successfully start the service on the box with
systemctl start openvpn@server

but when I try to do some from ansible I get:
failed: [laprouter] => {"failed": true, "item": ""}
msg: Failed to issue method call: Unit name openvpn@.service is not valid.

FATAL: all hosts have already failed -- aborting

Here is the part of the yml config:
- name: Ensure openvpn service enabled
  service: 
    name="openvpn@server"
    state=started


Is this an error in my configuration?

Michael DeHaan

unread,
Dec 23, 2013, 4:47:56 PM12/23/13
to ansible...@googlegroups.com
You shouldn't have to provide the "at" symbol here.


--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

shaun

unread,
Dec 23, 2013, 4:50:18 PM12/23/13
to ansible...@googlegroups.com
The @ symbol is required by systemd for dynamic daemons that load a specific configuration file.  For openvpn, you can have multiple .conf files for multiple openvpn daemons.  The @ is required for openvpn to work on a systemd system.  

e.g. on my client I have
systemctl start openvpn@workbench

where workbench is the name of the conf file:   /etc/openvpn/workbench.conf




--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/jajY_-n6qps/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

Michael DeHaan

unread,
Dec 23, 2013, 4:54:39 PM12/23/13
to ansible...@googlegroups.com
Hmm.

Please make sure there is a github ticket filed.   Or if you would like to work on this, that's fine too :)



shaun

unread,
Dec 23, 2013, 4:57:52 PM12/23/13
to ansible...@googlegroups.com
Will do.  I have been looking for an excuse to improve my python and figure out how ansible modules are written.  

I'll file a ticket too since I'm sure someone else will be able to patch it much more quickly than I.  

ayounggun

unread,
Feb 7, 2014, 3:31:07 PM2/7/14
to ansible...@googlegroups.com
Hi guys

I'm running from source and still getting this problem - is anyone else able to use @ signs in services?

task:
- name: enable and start eth0 service
  service: name=net...@eth0.service state=started enabled=yes

error:
TASK: [network | enable and start eth0 service] ******************************* 
<192.168.1.253> ESTABLISH CONNECTION FOR USER: root
<192.168.1.253> REMOTE_MODULE service name=net...@eth0.service state=started enabled=yes
<192.168.1.253> EXEC ['sshpass', '-d10', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/alex/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', '192.168.1.253', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1391803906.5-98641080919224 && echo $HOME/.ansible/tmp/ansible-tmp-1391803906.5-98641080919224'"]
<192.168.1.253> PUT /tmp/tmpxsF3YP TO /root/.ansible/tmp/ansible-tmp-1391803906.5-98641080919224/service
<192.168.1.253> EXEC ['sshpass', '-d10', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/alex/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', '192.168.1.253', "/bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1391803906.5-98641080919224/service; rm -rf /root/.ansible/tmp/ansible-tmp-1391803906.5-98641080919224/ >/dev/null 2>&1'"]
failed: [192.168.1.253] => {"failed": true, "item": ""}
msg: Failed to issue method call: Unit name netctl@.service is not valid.


FATAL: all hosts have already failed -- aborting


ansible version:

ansible 1.5 (devel 2d88246c9d) last updated 2014/02/07 20:06:49 (GMT +100)

shaun

unread,
Feb 7, 2014, 6:41:44 PM2/7/14
to ansible...@googlegroups.com

I haven't had enough time to actually fix this.  If someone else can do it more quickly, that would be awesome.  In the meantime, will have to use the command module.

Reply all
Reply to author
Forward
0 new messages