DIR will be stored on a local file on each machine, since the setting is custom to each user running the playbook. I've also realized the default value is actually useless; instead I should just check for the presence of the local file – since the structure of the Ansible dirs are known, this is simple enough to maintain. This will never be run remotely (it is part of a local setup for a remote process).
I suppose I was just wondering if there was an efficient way to do this rather than a series of tasks checking files, variables and states. I figured the use case may have been common enough for a special solution. For instance, let's say we needed the user to enter a password, but this password doesn't change so we want the user to only have to enter it once and the playbook "remembers" it for future runs. Is there a quick way to do this in Ansible, maybe in a single task? On Friday, October 14, 2022 at 12:36:28 PM UTC-7 [email protected] wrote: > Where will you store DIR's value? A local file on each machine? The > playbook can have a default value. Comparing the local machine's value to > the default is easy. If you plan to run the playbook remotely across > numerous machines who will answer the question? Ansible really excels at > executing the same tasks and configuring numerous systems the same way - > configuration management. You define a particular state. Ansible ensures > that is the state. If the machine doesn't match that state, it makes a > change. If the machine matches the state, no change is made. It is > "declarative". You describe a desired state. Ansible does what is necessary > to make that the state. > > Walter > -- > Walter Rowe, Division Chief > Infrastructure Services, OISM > Mobile: 202.355.4123 <(202)%20355-4123> > > On Oct 14, 2022, at 3:16 PM, Josh K <[email protected]> wrote: > > I have a playbook that depends on knowing where a certain git repository > is on the local machine. All of our developers have this repo somewhere, > but no assumptions can be made about the name of the dir or its location on > each dev's computer. > > What I want is this: some default variable that stores where this repo is > (DIR) after a user specifies it once. I've managed to define what I want in > a finite state machine: > > <Screen Shot 2022-10-14 at 12.09.30 PM.png> > > Is there an efficient way to implement this in Ansible? > > Without a better method, implementing this would require a lot of tasks > just dedicated to checking states, which seems tedious. I'm also not sure > how I would loop over the "is DIR valid" <---> "prompt" sequence. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/5eccb8ac-57b4-400b-89d8-b4e54f07c52an%40googlegroups.com > > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F5eccb8ac-57b4-400b-89d8-b4e54f07c52an%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C379c552e5c934dee13f308daae18d952%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638013719010397358%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eUII9cKOeCOoqUoxybPXc8Mjr0zaSmjZzx%2FTss4D6wc%3D&reserved=0> > . > > > <Screen Shot 2022-10-14 at 12.09.30 PM.png> > > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d91c2446-c6bf-4408-962d-1de975bf26f1n%40googlegroups.com.
