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

Fixes #22842 - Create .ansible.cfg in /etc/foreman-proxy #415

Merged
merged 1 commit into from
Apr 5, 2018

Conversation

dLobatog
Copy link
Member

@dLobatog dLobatog commented Mar 9, 2018

Currently we just mention it in the documentation https://github.com/theforeman/theforeman.org/pull/1033/files
but the installer should do this. The directory is used for some Ansible
tmp files

@theforeman-bot
Copy link
Member

@dLobatog, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

@ekohl
Copy link
Member

ekohl commented Mar 9, 2018

I feel state should not live in /usr. It violates the FHS.

@mmoll
Copy link
Contributor

mmoll commented Mar 10, 2018

I ran into this problem and I think the only way to work around this differenlty would be to make /usr/share/foreman-proxy writable for the proxy user or to bring the ~/.ansible dir via packaging.

@mmoll
Copy link
Contributor

mmoll commented Mar 10, 2018

The actual directory is in ${::foreman_proxy::dir}, BTW. It's different on non-Linux OSes.

@ekohl
Copy link
Member

ekohl commented Mar 10, 2018

In vanilla foreman we create files in /var and place a symlink in /usr pointing there. I'd prefer that over writing in /usr. We probably will need to consider a migration but packaging could take care of that.

@mmoll
Copy link
Contributor

mmoll commented Mar 10, 2018

@dLobatog could you check the vanilla ansible.cfg for file that are put into ~/.ansible per default and add configuration to put these into e.g ./var/lib/foreman-proxy/ansible. That should fix the original problem differently.

@mmoll
Copy link
Contributor

mmoll commented Mar 10, 2018

Thinking about it again, having ~foreman-proxy/.ansible linked to e.g. /var/lib/foreman-proxy/ansible makes indeed more sense...

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should never write in /usr and including it in the installer is wrong.

@@ -38,6 +38,12 @@
template_path => 'foreman_proxy/plugin/ansible.yml.erb',
}

file { '/usr/share/foreman-proxy/.ansible':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @mmoll said, this should be "${::foreman_proxy::dir}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @lpramuk mentioned we also need .ansible_galaxy for jobs that install roles from galaxy

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~foreman-proxy/.ansible
~foreman-proxy/.ansible_galaxy

we need both, the latter is for galaxy jobs

@theforeman-bot
Copy link
Member

@dLobatog, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

@theforeman-bot
Copy link
Member

@dLobatog, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to create /var/lib/foreman-proxy/ansible, /var/lib/foreman-proxy/ansible_galaxy and /var/lib/foreman-proxy/ansible.cfg. These are visible files - the links in /usr/share/foreman-proxy/.ansible (etc..) are invisible.

cc @ares @lpramuk @ekohl @mmoll

$shell = '/bin/false'
$user = 'foreman-proxy'
$dir = '/usr/share/foreman-proxy'
$var_dir = '/var/lib/foreman-proxy'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set for every OS.

@@ -19,13 +19,17 @@
Stdlib::Absolutepath $ansible_dir = $::foreman_proxy::plugin::ansible::params::ansible_dir,
Optional[Stdlib::Absolutepath] $working_dir = $::foreman_proxy::plugin::ansible::params::working_dir,
) inherits foreman_proxy::plugin::ansible::params {
file {"${::foreman_proxy::dir}/.ansible.cfg":
file {"${::foreman_proxy::var_dir}/ansible.cfg":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the etc dir instead since it's config, not state?

@dLobatog dLobatog force-pushed the 22842 branch 2 times, most recently from 1cdf94f to c6518ec Compare March 14, 2018 08:27
Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl Thanks for the review, I have set $var_dir for all OSs now, and also moved ansible.cfg to live in /etc/foreman-proxy/ansible.cfg as it's config. Once this is merged I'll have to update the docs to reflect the changes.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also fix these things in packaging.

ensure => file,
content => template('foreman_proxy/plugin/ansible.cfg.erb'),
owner => 'root',
group => $::foreman_proxy::user,
mode => '0640',
}
~> file { "${::foreman_proxy::dir}/.ansible.cfg":
ensure => link,
target => "${::foreman_proxy::etc}/ansible.cfg",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include /foreman-proxy like on line 22.

@@ -38,6 +42,26 @@
template_path => 'foreman_proxy/plugin/ansible.yml.erb',
}

file { "${::foreman_proxy::var_dir}/ansible":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The var_dir isn't created by packaging. It may be best to ensure that in foreman_proxy::config so all plugins can rely on it.

@dLobatog
Copy link
Member Author

Updated to make sure var_dir is automatically created & the ansible.cfg file is linked properly.

@ekohl What exactly do you have in mind to fix in packaging?

@ekohl
Copy link
Member

ekohl commented Mar 14, 2018

@dLobatog I think ensuring those directories and symlinks exist is something we should fix in packaging. It's also a better place to migrate any existing data. We'll still need to modify the etc directory here so that still makes sense.

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl Is there anything missing here? The var_dir is created in foreman_proxy::config , however if packaging creates it, the installer would just skip the creation and it's just a check that the file exists and has the correct owner.

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are green now

@sean797
Copy link
Member

sean797 commented Mar 21, 2018

Do we need to migrate any existing data? This could be done in foreman-installer as a pre hook, similar to https://github.com/Katello/katello-installer/blob/master/hooks/pre/30-upgrade.rb

@ares
Copy link
Member

ares commented Mar 22, 2018

I think the opposite aproach was requested

@sean797
Copy link
Member

sean797 commented Mar 22, 2018

Right, sorry - somehow I missed they are symlinks last night 👍

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything else missing here? @ekohl

@ekohl
Copy link
Member

ekohl commented Apr 4, 2018

theforeman/foreman-packaging#2348 should simplify this. With that you only need to change manifests/plugin/ansible.pp to place the file in /etc instead of /usr. All the other changes can be left out, but ensuring the symlink is a good thing because that means we don't rely on packaging which ensures this is a backwards compatible change.

I'll also have a look at a comparable Debian packaging change.

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl Alrighty, I've moved it to include only the /etc/ change. Everything else is saved in a branch 22842-backup in case we need to use it at some point.

@dLobatog dLobatog changed the title Fixes #22842 - Create .ansible in ~foreman-proxy Fixes #22842 - Create .ansible.cfg in /etc/foreman-proxy Apr 4, 2018
@ekohl ekohl merged commit 07d8b52 into theforeman:master Apr 5, 2018
@dLobatog dLobatog deleted the 22842 branch April 5, 2018 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants