ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Using Ansible to Manage install and update Apple OSX DHCP clients

    IT Discussion
    osx ansible homebrew apple automation
    5
    100
    7.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates @DustinB3403
      last edited by

      @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

      @stacksofplates So on your ansible server do you have a folder called playbooks and in that you have numerous different <something>.yml files each that do something?

      It's up to personal preference. I store things in ~/Documents/projects/ansible. Then in that I have a playbooks directory and a roles directory. Playbooks has the playbooks I need which is a single git repo and then each role has it's own git repo under roles.

      Your default ansible.cfg file is in /etc/ansible.cfg. It points you to /etc/ansible/hosts and /etc/ansible/roles I never use that. I always set an ansible.cfg in my playbooks directory. It overrides that and stores everything in that playbooks directory.

      1 Reply Last reply Reply Quote 1
      • DustinB3403D
        DustinB3403 @IRJ
        last edited by

        @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

        As @stacksofplates mentioned, connect with SSH how you do now, and I would create a special account just for ansible via playbook once you authenticat

        @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

        As @stacksofplates mentioned, connect with SSH how you do now, and I would create a special account just for ansible via playbook once you authenticat

        OKay that that would just be over ssh as our administrative user

        1 Reply Last reply Reply Quote 0
        • IRJI
          IRJ @stacksofplates
          last edited by

          @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

          @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

          So going out on the wild assumption that I wasn't on my couch right now, how would ansible find my clients?

          No credentials have been set anywhere - how do I add my clients?

          So how you use credentials depends on how you have them set up on your systems. If you have a user that can access all of them, then you can use that user. If you don't, you'll have to call separate plays for the different systems.

          If you running an ansible ad-hoc command you can do:

          ansible -i <path to inventory> group-name -m setup -u <username> 
          

          SSH keys are preferable, but if you don't have them you can pass a -k to ask for the SSH password. -K is the sudo password flag and goes along with -b for become (meaning become another user).

          To run a playbook, just have your user defined like I showed in the other thread and become as true if you need it.

          @DustinB3403 this is what I am talking about. Use your SSH root user to run the user creation playbook.

          DustinB3403D 1 Reply Last reply Reply Quote 0
          • DustinB3403D
            DustinB3403 @IRJ
            last edited by

            @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

            @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

            @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

            So going out on the wild assumption that I wasn't on my couch right now, how would ansible find my clients?

            No credentials have been set anywhere - how do I add my clients?

            So how you use credentials depends on how you have them set up on your systems. If you have a user that can access all of them, then you can use that user. If you don't, you'll have to call separate plays for the different systems.

            If you running an ansible ad-hoc command you can do:

            ansible -i <path to inventory> group-name -m setup -u <username> 
            

            SSH keys are preferable, but if you don't have them you can pass a -k to ask for the SSH password. -K is the sudo password flag and goes along with -b for become (meaning become another user).

            To run a playbook, just have your user defined like I showed in the other thread and become as true if you need it.

            @DustinB3403 this is what I am talking about. Use your SSH root user to run the user creation playbook.

            So my inventory file is currently in (I assume) is /etc/ansible/hosts right?

            Also I don't think that is how you create users on OSX cli (have to confirm)

            1 Reply Last reply Reply Quote 0
            • stacksofplatesS
              stacksofplates
              last edited by stacksofplates

              So here's my tree view for that directory

              ansible
                 ├── playbooks
                    ├── ansible.cfg
                    ├── apache.yml
                    ├── group_vars
                    ├── inventory
                    ├── Makefile
                    └── roles
                      ├── apache
                      ├── firewalld
                      ├── grafana
                      ├── nginx
                      ├── node-exporter
                      └── prometheus
              
              
              DustinB3403D 1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403 @stacksofplates
                last edited by

                @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                So here's my tree view for that directory

                ansible
                   ├── playbooks
                      ├── group_vars
                      ├── inventory
                      └── roles
                   └── roles
                        ├── apache
                        ├── firewalld
                        ├── grafana
                        ├── nginx
                        ├── node-exporter
                        └── prometheus
                
                

                I assume this actually looks like

                etc
                └──ansible
                	├── playbooks
                	├── group_var
                	├── inventory
                	└── roles
                └── roles
                	├── apache
                	├── firewalld
                	├── grafana
                	├── nginx
                	├── node-exporter
                	└── prometheus
                
                stacksofplatesS 1 Reply Last reply Reply Quote 0
                • stacksofplatesS
                  stacksofplates @DustinB3403
                  last edited by stacksofplates

                  @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                  @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                  So here's my tree view for that directory

                  ansible
                     ├── playbooks
                        ├── group_vars
                        ├── inventory
                        └── roles
                     └── roles
                          ├── apache
                          ├── firewalld
                          ├── grafana
                          ├── nginx
                          ├── node-exporter
                          └── prometheus
                  
                  

                  I assume this actually looks like

                  etc
                  └──ansible
                  ├── playbooks
                  ├── group_var
                  ├── inventory
                  └── roles
                  └── roles
                  ├── apache
                  ├── firewalld
                  ├── grafana
                  ├── nginx
                  ├── node-exporter
                  └── prometheus

                  No it's under ~/Documents/projects/ansible like I mentioned above.

                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    To ask, can I add hosts by hostname to the host file rather than by IP address. Being these systems are portable, their IP can change at a moments notice and would cause all kinds of SSH complaints like WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

                    IRJI stacksofplatesS 2 Replies Last reply Reply Quote 0
                    • IRJI
                      IRJ @DustinB3403
                      last edited by

                      @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                      To ask, can I add hosts by hostname to the host file rather than by IP address. Being these systems are portable, their IP can change at a moments notice and would cause all kinds of SSH complaints like WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

                      yes. That was one of the first things I recommended 😛

                      1 Reply Last reply Reply Quote 0
                      • stacksofplatesS
                        stacksofplates @DustinB3403
                        last edited by

                        @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                        To ask, can I add hosts by hostname to the host file rather than by IP address. Being these systems are portable, their IP can change at a moments notice and would cause all kinds of SSH complaints like WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

                        Yeah that's why I said you can either use FQDN or IP address and why I also mentioned disabling host key checking for Ansible. There are times not to disable it but shouldn't matter in this case.

                        1 Reply Last reply Reply Quote 0
                        • ObsolesceO
                          Obsolesce
                          last edited by Obsolesce

                          So you are going to have SSH open on everything while allowing root and/or password login?

                          TF?

                          DustinB3403D IRJI stacksofplatesS 3 Replies Last reply Reply Quote 0
                          • DustinB3403D
                            DustinB3403 @Obsolesce
                            last edited by DustinB3403

                            @Obsolesce said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                            So you are going to have SSH open on everything while allowing root and/or password login?

                            TF?

                            SSH is open on Mac OSX by default already, nothing I'm doing is opening that.

                            I'm looking to setup SSH keys alsoI've already setup SSH keys, so I'm not sending passwords.

                            This is also still very early stage testing and things can be changed/improved well before deployment.

                            1 Reply Last reply Reply Quote 2
                            • IRJI
                              IRJ @Obsolesce
                              last edited by

                              @Obsolesce said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                              So you are going to have SSH open on everything while allowing root and/or password login?

                              TF?

                              You can use keys (recommended). Also, ideally you only run your management tools from one subnet. You only open ssh on the clients to that subnet. No reason for client1 to be able to SSH to client2. You could also get more restrictive and only allow specific IPs.

                              1 Reply Last reply Reply Quote 0
                              • stacksofplatesS
                                stacksofplates @Obsolesce
                                last edited by stacksofplates

                                @Obsolesce said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                So you are going to have SSH open on everything while allowing root and/or password login?

                                TF?

                                Maybe tone it down a tad since you apparently don't understand what's happening. We are recommending using keys for authentication. Using the password only to set that up. Second where did the allowing root come from? That never came up. Third I know you're on the Salt is the savior of everything train, but SSH is just as secure as ZeroMQ. If you limit where SSH access can come from to a subnet (like @IRJ mentioned) or a single machine it's pretty much exactly what you have with ZeroMQ but just not a message bus.

                                Plus this is ignoring the fact that when you get to fully immutable infrastructure (I realize the Macs aren't that) you can leverage Ansible through tools like Packer to build your image and never need SSH after the fact because you don't ever log in again at all.

                                ObsolesceO 2 Replies Last reply Reply Quote 1
                                • ObsolesceO
                                  Obsolesce @stacksofplates
                                  last edited by

                                  @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                  Maybe tone it down a tad since you apparently don't understand what's happening. We are recommending using keys for authentication.

                                  Yeah, I didn't read all the way down before I wrote that. I don't always have time to read past the first few, and it wasn't mentioned in what I did read. My bad there.

                                  1 Reply Last reply Reply Quote 1
                                  • ObsolesceO
                                    Obsolesce @stacksofplates
                                    last edited by

                                    @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                    Third I know you're on the Salt is the savior of everything train, but SSH is just as secure as ZeroMQ.

                                    No, it's a preference, and for some things Salt works better, nothing more. Just like Fedora is a preference, but I use Ubuntu and others as well where they work better.

                                    At work, we use Ansible, and it works well for that case. There may be a secondary need for config management in the immediate area I work with, and for that SaltStack will work better naturally vs Ansible.

                                    Just FYI, I take every technology case by case. Just because I show a preference, does not EVER mean I choose that by default. I always use the best option for that specific case, regardless of my preference, so long as I have a say.

                                    stacksofplatesS 1 Reply Last reply Reply Quote 0
                                    • stacksofplatesS
                                      stacksofplates @Obsolesce
                                      last edited by stacksofplates

                                      @Obsolesce said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                      @stacksofplates said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                      Third I know you're on the Salt is the savior of everything train, but SSH is just as secure as ZeroMQ.

                                      No, it's a preference, and for some things Salt works better, nothing more. Just like Fedora is a preference, but I use Ubuntu and others as well where they work better.

                                      At work, we use Ansible, and it works well for that case. There may be a secondary need for config management in the immediate area I work with, and for that SaltStack will work better naturally vs Ansible.

                                      Just FYI, I take every technology case by case. Just because I show a preference, does not EVER mean I choose that by default. I always use the best option for that specific case, regardless of my preference, so long as I have a say.

                                      I agree. Ansible isn't the best use case for laptop management unless you're using an SD-WAN or you are really immutable with them (kind of like what Google does with their Chromebooks).

                                      I mean there's "workarounds" to do remote callbacks to your config management platform (like remote triggers with Jenkins and provisioning callbacks in Tower or ansible-pull) but they are a little more advanced and aren't for everyone.

                                      1 Reply Last reply Reply Quote 0
                                      • DustinB3403D
                                        DustinB3403
                                        last edited by

                                        Okay so I'm just now getting back to this after the break and the Monday rush.

                                        I'm having an issue that doesn't make sense to me.

                                        I can't use ansible to ping any of my hosts (the one of interest is everything dbeue) but I can ssh in without having to enter a password so keyauth is working.

                                        e1L3Z9m2af.png

                                        What am I missing or have misconfigured here?

                                        IRJI 1 Reply Last reply Reply Quote 0
                                        • IRJI
                                          IRJ @DustinB3403
                                          last edited by

                                          @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                          Okay so I'm just now getting back to this after the break and the Monday rush.

                                          I'm having an issue that doesn't make sense to me.

                                          I can't use ansible to ping any of my hosts (the one of interest is everything dbeue) but I can ssh in without having to enter a password so keyauth is working.

                                          e1L3Z9m2af.png

                                          What am I missing or have misconfigured here?

                                          That looks like a DNS issue.

                                          DustinB3403D 1 Reply Last reply Reply Quote 0
                                          • DustinB3403D
                                            DustinB3403 @IRJ
                                            last edited by

                                            @IRJ will add the IP and test again, but I'm pretty certain I was unable to ping even by IP address.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 2 / 5
                                            • First post
                                              Last post