<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto"><a href="http://docs.ansible.com/ansible/mount_module.html" rel="nofollow">Mount module</a></p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<p dir="auto">Tested on both versions:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

</code></pre></div>
<p dir="auto">and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]"><pre class="notranslate"><code class="notranslate">ansible-playbook 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">Default</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Manager OS: CentOS Linux release 7.3.1611 (Core)<br>
TargetOS (Tested): Ubuntu 16.04, CentOS 6.8</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Mount module do not allow to create several mount points with name: "none", so it is impossible to use this module to manage swap files mount point. During this operation this module overwrites already existent line.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: Swapfile | Install | Add swap entry in fstab
  become: True
  mount:
    name: none
    src: &quot;/swapfile&quot;
    fstype: swap
    opts: sw
    dump: 0
    passno: 0
    state: present"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Swapfile | Install | Add swap entry in fstab</span>
  <span class="pl-ent">become</span>: <span class="pl-c1">True</span>
  <span class="pl-ent">mount</span>:
    <span class="pl-ent">name</span>: <span class="pl-s">none</span>
    <span class="pl-ent">src</span>: <span class="pl-s"><span class="pl-pds">"</span>/swapfile<span class="pl-pds">"</span></span>
    <span class="pl-ent">fstype</span>: <span class="pl-s">swap</span>
    <span class="pl-ent">opts</span>: <span class="pl-s">sw</span>
    <span class="pl-ent">dump</span>: <span class="pl-c1">0</span>
    <span class="pl-ent">passno</span>: <span class="pl-c1">0</span>
    <span class="pl-ent">state</span>: <span class="pl-s">present</span></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">I am expecting to get fstab file with two swap lines. One from default Ubuntu installation, and one from this command. Should be looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
# / was on /dev/sda1 during installation
UUID=b3130c85-0e01-4501-8243-5d8982451909 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=8f70f922-924e-4951-ba10-04d61297b8f7 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
/swapfile   none    swap    sw    0   0"><pre class="notranslate"><code class="notranslate"># /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
# / was on /dev/sda1 during installation
UUID=b3130c85-0e01-4501-8243-5d8982451909 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=8f70f922-924e-4951-ba10-04d61297b8f7 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
/swapfile   none    swap    sw    0   0
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Actually default swap entry is missing after this execution, and fstab looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
# / was on /dev/sda1 during installation
UUID=b3130c85-0e01-4501-8243-5d8982451909 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
//swapfile none swap sw 0 0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0"><pre class="notranslate"><code class="notranslate"># /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
# / was on /dev/sda1 during installation
UUID=b3130c85-0e01-4501-8243-5d8982451909 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
//swapfile none swap sw 0 0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
</code></pre></div>
<p dir="auto"><a href="https://gist.github.com/insspb/81c1f2c749d860652929203b64d37a70">Execution log with -vvvv enabled (Gist link)</a></p>
<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/changyy/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/changyy">@changyy</a> on 2016-01-14T06:22:57Z</p>
<h5 dir="auto">ISSUE TYPE</h5>
<p dir="auto">Feature Idea</p>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">service module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Hi,</p>
<p dir="auto">I would like to use service module to finish my job but current structure of the service module is not good enough.</p>
<p dir="auto">Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ service nginx
Usage: /etc/init.d/nginx {start|stop|status|restart|reload|force-reload|upgrade|configtest}
$ sudo service nginx configtest 
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful"><pre class="notranslate"><code class="notranslate">$ service nginx
Usage: /etc/init.d/nginx {start|stop|status|restart|reload|force-reload|upgrade|configtest}
$ sudo service nginx configtest 
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
</code></pre></div>
<p dir="auto">But the current status of the Ansible service module is not supported for this usage. There are only predefined states, ['running', 'started', 'stopped', 'restarted', 'reloaded'], could be used.</p>
<p dir="auto">And using shell module will get a warning message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: test nginx config
  shell: service nginx configtest
  register: result
  changed_when: &quot;result.rc != 0&quot;
  always_run: yes

$ ansible running...
[WARNING]: Consider using service module rather than running service"><pre class="notranslate"><code class="notranslate">- name: test nginx config
  shell: service nginx configtest
  register: result
  changed_when: "result.rc != 0"
  always_run: yes

$ ansible running...
[WARNING]: Consider using service module rather than running service
</code></pre></div>
<p dir="auto">So I just try to make a patch for it and name the new state "comannd" for demo the usage. Please feel free to modify the keywords or any codes. I just to present a demo solution from my thinking.</p>
<p dir="auto">Usage:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: test nginx config
  service: name=nginx state=command arguments=configtest"><pre class="notranslate"><code class="notranslate">- name: test nginx config
  service: name=nginx state=command arguments=configtest
</code></pre></div>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="126586307" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/2809" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/2809/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/2809">ansible/ansible-modules-core#2809</a></p>